Zelda Classic Coverage Report


Directory: src/
File: src/zc/zc_sys.cpp
Date: 2023-03-10 04:06:16
Exec Total Coverage
Lines: 1778 4253 41.8%
Functions: 128 340 37.6%
Branches: 953 2718 35.1%

Line Branch Exec Source
1 //--------------------------------------------------------
2 // Zelda Classic
3 // by Jeremy Craner, 1999-2000
4 //
5 // zc_sys.cc
6 //
7 // System functions, input handlers, GUI stuff, etc.
8 // for Zelda Classic.
9 //
10 //--------------------------------------------------------
11
12 // to prevent <map> from generating errors
13 #define __GTHREAD_HIDE_WIN32API 1
14
15 #include "precompiled.h" //always first
16 #include "zc_sys.h"
17
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29
18 #include <stdio.h>
19 #include <stdlib.h>
20 #include <string.h>
21 #include <math.h>
22 #include <map>
23 #include <filesystem>
24 #include <ctype.h>
25 #include <sstream>
26 #include "base/zc_alleg.h"
27 #include "gamedata.h"
28 #include "zc_init.h"
29 #include "init.h"
30 #include "replay.h"
31 #include "cheats.h"
32 #include "render.h"
33 #include "base/zc_math.h"
34 #include "base/zapp.h"
35 #include "dialog/cheatkeys.h"
36
37 #ifdef ALLEGRO_DOS
38 #include <unistd.h>
39 #endif
40
41 #include "metadata/metadata.h"
42 #include "zelda.h"
43 #include "tiles.h"
44 #include "base/colors.h"
45 #include "pal.h"
46 #include "base/zsys.h"
47 #include "qst.h"
48 #include "zc_sys.h"
49 #include "play_midi.h"
50 #include "debug.h"
51 #include "jwin_a5.h"
52 #include "base/jwinfsel.h"
53 #include "base/gui.h"
54 #include "midi.h"
55 #include "subscr.h"
56 #include "maps.h"
57 #include "sprite.h"
58 #include "guys.h"
59 #include "hero.h"
60 #include "title.h"
61 #include "particles.h"
62 #include "zconsole.h"
63 #include "ffscript.h"
64 #include "dialog/info.h"
65 #include "dialog/alert.h"
66 #include <fmt/format.h>
67
68 #ifdef __EMSCRIPTEN__
69 #include "base/emscripten_utils.h"
70 #endif
71
72 extern FFScript FFCore;
73 extern bool Playing;
74 int32_t sfx_voice[WAV_COUNT];
75 int32_t d_stringloader(int32_t msg,DIALOG *d,int32_t c);
76 int32_t d_midilist_proc(int32_t msg,DIALOG *d,int32_t c);
77
78 extern byte monochrome_console;
79
80 extern FONT *lfont;
81 extern HeroClass Hero;
82 extern FFScript FFCore;
83 extern ZModule zcm;
84 extern zcmodule moduledata;
85 extern sprite_list guys, items, Ewpns, Lwpns, Sitems, chainlinks, decorations;
86 extern particle_list particles;
87 extern int32_t loadlast;
88 extern word passive_subscreen_doscript;
89 extern bool passive_subscreen_waitdraw;
90 extern char *sfx_string[WAV_COUNT];
91 byte use_dwm_flush;
92 byte use_save_indicator;
93 byte midi_patch_fix;
94 bool midi_paused=false;
95 int32_t paused_midi_pos = 0;
96 byte midi_suspended = 0;
97 byte callback_switchin = 0;
98 byte zc_192b163_warp_compatibility;
99 char modulepath[2048];
100 bool epilepsyFlashReduction;
101 signed char pause_in_background_menu_init = 0;
102 byte pause_in_background = 0;
103 bool is_sys_pal = false;
104 static bool load_control_called_this_frame;
105 extern PALETTE* hw_palette;
106 extern bool update_hw_pal;
107 extern const char* dmaplist(int32_t index, int32_t* list_size);
108
109 extern bool kb_typing_mode; //script only, for disbaling key presses affecting Hero, etc.
110 extern int32_t cheat_modifier_keys[4]; //two options each, default either control and either shift
111 //extern byte refresh_select_screen;
112 //extern movingblock mblock2; //mblock[4]?
113 //extern int32_t db;
114
115 static const char *ZC_str = "Zelda Classic";
116 extern char save_file_name[1024];
117 #ifdef ALLEGRO_DOS
118 const char *qst_dir_name = "dos_qst_dir";
119 #elif defined(ALLEGRO_WINDOWS)
120 const char *qst_dir_name = "win_qst_dir";
121 static const char *qst_module_name = "current_module";
122 #elif defined(ALLEGRO_LINUX)
123 const char *qst_dir_name = "linux_qst_dir";
124 static const char *qst_module_name = "current_module";
125 #elif defined(__APPLE__)
126 const char *qst_dir_name = "osx_qst_dir";
127 static const char *qst_module_name = "current_module";
128 #endif
129 #ifdef ALLEGRO_LINUX
130 static const char *samplepath = "samplesoundset/patches.dat";
131 #endif
132 char qst_files_path[2048];
133
134 #ifdef _MSC_VER
135 #define getcwd _getcwd
136 #endif
137
138 bool rF11();
139 bool rI();
140 bool rQ();
141 bool zc_key_pressed();
142
143 #ifdef _WIN32
144
145 // This should only be necessary for MinGW, since it doesn't have a dwmapi.h. Add another #ifdef if you like.
146 extern "C"
147 {
148 typedef HRESULT(WINAPI *t_DwmFlush)();
149 typedef HRESULT(WINAPI *t_DwmIsCompositionEnabled)(BOOL *pfEnabled);
150 }
151
152 void do_DwmFlush()
153 {
154 static HMODULE shell = LoadLibrary("dwmapi.dll");
155
156 if(!shell)
157 return;
158
159 static t_DwmFlush flush=reinterpret_cast<t_DwmFlush>(GetProcAddress(shell, "DwmFlush"));
160 static t_DwmIsCompositionEnabled isEnabled=reinterpret_cast<t_DwmIsCompositionEnabled>(GetProcAddress(shell, "DwmIsCompositionEnabled"));
161
162 BOOL enabled;
163 isEnabled(&enabled);
164
165 if(isEnabled)
166 flush();
167 }
168
169 #endif // _WIN32
170
171 82019 bool flash_reduction_enabled(bool check_qr)
172 {
173
4/4
✓ Branch 0 taken 79798 times.
✓ Branch 1 taken 2221 times.
✓ Branch 2 taken 79342 times.
✓ Branch 3 taken 81563 times.
82019 return (check_qr && get_bit(quest_rules, qr_EPILEPSY)) || epilepsyFlashReduction || replay_is_debug();
174 }
175
176 // Dialogue largening
177 void large_dialog(DIALOG *d)
178 {
179 large_dialog(d, 1.5);
180 }
181
182 void large_dialog(DIALOG *d, float RESIZE_AMT)
183 {
184 if(!d[0].d1)
185 {
186 d[0].d1 = 1;
187 int32_t oldwidth = d[0].w;
188 int32_t oldheight = d[0].h;
189 int32_t oldx = d[0].x;
190 int32_t oldy = d[0].y;
191 d[0].x -= int32_t(d[0].w/RESIZE_AMT);
192 d[0].y -= int32_t(d[0].h/RESIZE_AMT);
193 d[0].w = int32_t(d[0].w*RESIZE_AMT);
194 d[0].h = int32_t(d[0].h*RESIZE_AMT);
195
196 for(int32_t i=1; d[i].proc !=NULL; i++)
197 {
198 // Place elements horizontally
199 double xpc = ((double)(d[i].x - oldx) / (double)oldwidth);
200 d[i].x = int32_t(d[0].x + (xpc*d[0].w));
201
202 if(d[i].proc != d_stringloader)
203 {
204 if(d[i].proc==d_bitmap_proc)
205 {
206 d[i].w *= 2;
207 }
208 else d[i].w = int32_t(d[i].w*RESIZE_AMT);
209 }
210
211 // Place elements vertically
212 double ypc = ((double)(d[i].y - oldy) / (double)oldheight);
213 d[i].y = int32_t(d[0].y + (ypc*d[0].h));
214
215 // Vertically resize elements
216 if(d[i].proc == jwin_edit_proc || d[i].proc == jwin_check_proc || d[i].proc == jwin_checkfont_proc)
217 {
218 d[i].h = int32_t((double)d[i].h*1.5);
219 }
220 else if(d[i].proc == jwin_droplist_proc)
221 {
222 d[i].y += int32_t((double)d[i].h*0.25);
223 d[i].h = int32_t((double)d[i].h*1.25);
224 }
225 else if(d[i].proc==d_bitmap_proc)
226 {
227 d[i].h *= 2;
228 }
229 else d[i].h = int32_t(d[i].h*RESIZE_AMT);
230
231 // Fix frames
232 if(d[i].proc == jwin_frame_proc)
233 {
234 d[i].x++;
235 d[i].y++;
236 d[i].w-=4;
237 d[i].h-=4;
238 }
239 }
240 }
241
242 for(int32_t i=1; d[i].proc!=NULL; i++)
243 {
244 if(d[i].proc==jwin_slider_proc)
245 continue;
246
247 // Bigger font
248 auto& proc = d[i].proc;
249 bool bigfontproc = (proc != d_midilist_proc && proc != jwin_droplist_proc && proc != jwin_abclist_proc && proc != jwin_list_proc);
250 bool a5proc = (proc == jwin_win_proc_a5 || proc == jwin_tab_proc_a5 || proc == jwin_text_proc_a5 || proc == jwin_ctext_proc_a5 || proc == jwin_rtext_proc_a5 || proc == new_text_proc_a5 || proc == jwin_button_proc_a5
251 || proc == jwin_selcolor_proc_a5 || proc == jwin_color_swatch_a5);
252
253 if(!d[i].dp2 && bigfontproc)
254 {
255 d[i].dp2 = a5proc ? (void*)get_custom_font_a5(CFONT_DLG) : (void*)get_custom_font(CFONT_DLG);
256 }
257 else if(!bigfontproc)
258 {
259 ((ListData *)d[i].dp)->font = &lfont_l;
260 ((ListData *)d[i].dp)->a5font = &a5fonts[font_lfont_l];
261 }
262
263 // Make checkboxes work
264 if(d[i].proc == jwin_check_proc)
265 d[i].proc = jwin_checkfont_proc;
266 else if(d[i].proc == jwin_radio_proc)
267 d[i].proc = jwin_radiofont_proc;
268 else if(d[i].proc == jwin_radio_proc_a5)
269 d[i].proc = jwin_radiofont_proc_a5;
270 }
271
272 jwin_center_dialog(d);
273 }
274
275
276 /**********************************/
277 /******** System functions ********/
278 /**********************************/
279
280 static char cfg_sect[] = "zeldadx"; //We need to rename this.
281 static char ctrl_sect[] = "Controls";
282 static char sfx_sect[] = "Volume";
283
284 int32_t d_dummy_proc(int32_t,DIALOG *,int32_t)
285 {
286 return D_O_K;
287 }
288
289 bool checkcheat(Cheat cheat)
290 {
291 if(cheatkeys[cheat][0] && zc_readkey(cheatkeys[cheat][0]))
292 return true; //Main key pressed
293 if(cheatkeys[cheat][1] && zc_readkey(cheatkeys[cheat][1]))
294 return true; //Alt key pressed
295 return false;
296 }
297 29 void load_default_cheatkeys()
298 {
299 29 memset(cheatkeys, 0, sizeof(cheatkeys));
300 29 cheatkeys[Cheat::Life][0] = KEY_H;
301 29 cheatkeys[Cheat::Life][1] = KEY_ASTERISK;
302 29 cheatkeys[Cheat::Magic][0] = KEY_M;
303 29 cheatkeys[Cheat::Magic][1] = KEY_SLASH_PAD;
304 29 cheatkeys[Cheat::Rupies][0] = KEY_R;
305 29 cheatkeys[Cheat::Bombs][0] = KEY_B;
306 29 cheatkeys[Cheat::Arrows][0] = KEY_A;
307 29 cheatkeys[Cheat::Clock][0] = KEY_I;
308 29 cheatkeys[Cheat::Walls][0] = KEY_F11;
309 29 cheatkeys[Cheat::Fast][0] = KEY_Q;
310 29 cheatkeys[Cheat::Light][0] = KEY_L;
311 29 cheatkeys[Cheat::IgnoreSideView][0] = KEY_V;
312 29 cheatkeys[Cheat::Kill][0] = KEY_K;
313 29 cheatkeys[Cheat::GoTo][0] = KEY_G;
314 29 cheatkeys[Cheat::TrigSecrets][0] = KEY_S;
315 29 cheatkeys[Cheat::ShowL0][0] = KEY_0;
316 29 cheatkeys[Cheat::ShowL1][0] = KEY_1;
317 29 cheatkeys[Cheat::ShowL2][0] = KEY_2;
318 29 cheatkeys[Cheat::ShowL3][0] = KEY_3;
319 29 cheatkeys[Cheat::ShowL4][0] = KEY_4;
320 29 cheatkeys[Cheat::ShowL5][0] = KEY_5;
321 29 cheatkeys[Cheat::ShowL6][0] = KEY_6;
322 29 cheatkeys[Cheat::ShowFFC][0] = KEY_7;
323 29 cheatkeys[Cheat::ShowSprites][0] = KEY_8;
324 29 cheatkeys[Cheat::ShowWalkability][0] = KEY_W;
325 29 cheatkeys[Cheat::ShowEffects][0] = KEY_E;
326 29 cheatkeys[Cheat::ShowOverhead][0] = KEY_O;
327 29 cheatkeys[Cheat::ShowPushblock][0] = KEY_P;
328 29 cheatkeys[Cheat::ShowHitbox][0] = KEY_C;
329 29 cheatkeys[Cheat::ShowFFCScripts][0] = KEY_F;
330 29 }
331 29 void load_game_configs()
332 {
333 29 strcpy(moduledata.module_name,zc_get_config("ZCMODULE",qst_module_name,"classic.zmod"));
334 29 joystick_index = zc_get_config(ctrl_sect,"joystick_index",0);
335 29 js_stick_1_x_stick = zc_get_config(ctrl_sect,"js_stick_1_x_stick",0);
336 29 js_stick_1_x_axis = zc_get_config(ctrl_sect,"js_stick_1_x_axis",0);
337 29 js_stick_1_x_offset = zc_get_config(ctrl_sect,"js_stick_1_x_offset",0) ? 128 : 0;
338 29 js_stick_1_y_stick = zc_get_config(ctrl_sect,"js_stick_1_y_stick",0);
339 29 js_stick_1_y_axis = zc_get_config(ctrl_sect,"js_stick_1_y_axis",1);
340 29 js_stick_1_y_offset = zc_get_config(ctrl_sect,"js_stick_1_y_offset",0) ? 128 : 0;
341 29 js_stick_2_x_stick = zc_get_config(ctrl_sect,"js_stick_2_x_stick",1);
342 29 js_stick_2_x_axis = zc_get_config(ctrl_sect,"js_stick_2_x_axis",0);
343 29 js_stick_2_x_offset = zc_get_config(ctrl_sect,"js_stick_2_x_offset",0) ? 128 : 0;
344 29 js_stick_2_y_stick = zc_get_config(ctrl_sect,"js_stick_2_y_stick",1);
345 29 js_stick_2_y_axis = zc_get_config(ctrl_sect,"js_stick_2_y_axis",1);
346 29 js_stick_2_y_offset = zc_get_config(ctrl_sect,"js_stick_2_y_offset",0) ? 128 : 0;
347 29 analog_movement = (zc_get_config(ctrl_sect,"analog_movement",1));
348
349 //cheat modifier keya
350 29 cheat_modifier_keys[0] = zc_get_config(ctrl_sect,"key_cheatmod_a1",KEY_ZC_LCONTROL);
351 29 cheat_modifier_keys[1] = zc_get_config(ctrl_sect,"key_cheatmod_a2",0);
352 29 cheat_modifier_keys[2] = zc_get_config(ctrl_sect,"key_cheatmod_b1",KEY_ZC_RCONTROL);
353 29 cheat_modifier_keys[3] = zc_get_config(ctrl_sect,"key_cheatmod_b2",0);
354
355 //cheat keys
356 29 load_default_cheatkeys();
357 char buf[256];
358 29 al_trace("START CHEATS\n");
359
2/2
✓ Branch 0 taken 1015 times.
✓ Branch 1 taken 29 times.
1044 for(size_t q = 1; q < Cheat::Last; ++q)
360 {
361
1/2
✓ Branch 0 taken 1015 times.
✗ Branch 1 not taken.
1015 if(!bindable_cheat((Cheat)q)) continue;
362 1015 std::string cheatname = cheat_to_string((Cheat)q);
363
1/2
✓ Branch 0 taken 1015 times.
✗ Branch 1 not taken.
1015 util::lowerstr(cheatname);
364 1015 sprintf(buf, "key_cheat_%s_main", cheatname.c_str());
365
1/2
✓ Branch 0 taken 1015 times.
✗ Branch 1 not taken.
1015 al_trace("%s = %d\n", buf, cheatkeys[q][0]);
366
1/2
✓ Branch 0 taken 1015 times.
✗ Branch 1 not taken.
1015 cheatkeys[q][0] = zc_get_config(ctrl_sect,buf,cheatkeys[q][0]);
367 1015 sprintf(buf, "key_cheat_%s_alt", cheatname.c_str());
368
1/2
✓ Branch 0 taken 1015 times.
✗ Branch 1 not taken.
1015 al_trace("%s = %d\n", buf, cheatkeys[q][1]);
369
1/2
✓ Branch 0 taken 1015 times.
✗ Branch 1 not taken.
1015 cheatkeys[q][1] = zc_get_config(ctrl_sect,buf,cheatkeys[q][1]);
370 1015 }
371 29 al_trace("END CHEATS\n");
372
373
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if((uint32_t)joystick_index >= MAX_JOYSTICKS)
374 joystick_index = 0;
375
376 29 Akey = zc_get_config(ctrl_sect,"key_a",KEY_Z);
377 29 Bkey = zc_get_config(ctrl_sect,"key_b",KEY_X);
378 29 Skey = zc_get_config(ctrl_sect,"key_s",KEY_ENTER);
379 29 Lkey = zc_get_config(ctrl_sect,"key_l",KEY_Q);
380 29 Rkey = zc_get_config(ctrl_sect,"key_r",KEY_W);
381 29 Pkey = zc_get_config(ctrl_sect,"key_p",KEY_SPACE);
382 29 Exkey1 = zc_get_config(ctrl_sect,"key_ex1",KEY_A);
383 29 Exkey2 = zc_get_config(ctrl_sect,"key_ex2",KEY_S);
384 29 Exkey3 = zc_get_config(ctrl_sect,"key_ex3",KEY_D);
385 29 Exkey4 = zc_get_config(ctrl_sect,"key_ex4",KEY_C);
386
387 29 DUkey = zc_get_config(ctrl_sect,"key_up", KEY_UP);
388 29 DDkey = zc_get_config(ctrl_sect,"key_down", KEY_DOWN);
389 29 DLkey = zc_get_config(ctrl_sect,"key_left", KEY_LEFT);
390 29 DRkey = zc_get_config(ctrl_sect,"key_right",KEY_RIGHT);
391
392 29 Abtn = zc_get_config(ctrl_sect,"btn_a",2);
393 29 Bbtn = zc_get_config(ctrl_sect,"btn_b",1);
394 29 Sbtn = zc_get_config(ctrl_sect,"btn_s",10);
395 29 Mbtn = zc_get_config(ctrl_sect,"btn_m",9);
396 29 Lbtn = zc_get_config(ctrl_sect,"btn_l",5);
397 29 Rbtn = zc_get_config(ctrl_sect,"btn_r",6);
398 29 Pbtn = zc_get_config(ctrl_sect,"btn_p",12);
399 29 Exbtn1 = zc_get_config(ctrl_sect,"btn_ex1",7);
400 29 Exbtn2 = zc_get_config(ctrl_sect,"btn_ex2",8);
401 29 Exbtn3 = zc_get_config(ctrl_sect,"btn_ex3",4);
402 29 Exbtn4 = zc_get_config(ctrl_sect,"btn_ex4",3);
403
404 29 DUbtn = zc_get_config(ctrl_sect,"btn_up",13);
405 29 DDbtn = zc_get_config(ctrl_sect,"btn_down",14);
406 29 DLbtn = zc_get_config(ctrl_sect,"btn_left",15);
407 29 DRbtn = zc_get_config(ctrl_sect,"btn_right",16);
408
409 29 epilepsyFlashReduction = zc_get_config(cfg_sect,"epilepsy_flash_reduction",0);
410
411 29 digi_volume = zc_get_config(sfx_sect,"digi",248);
412 29 midi_volume = zc_get_config(sfx_sect,"midi",255);
413 29 sfx_volume = zc_get_config(sfx_sect,"sfx",248);
414 29 emusic_volume = zc_get_config(sfx_sect,"emusic",248);
415 29 pan_style = zc_get_config(sfx_sect,"pan",1);
416 // 1 <= zcmusic_bufsz <= 128
417 29 zcmusic_bufsz = vbound(zc_get_config(sfx_sect,"zcmusic_bufsz",64),1,128);
418 29 volkeys = zc_get_config(sfx_sect,"volkeys",0)!=0;
419 29 zc_vsync = zc_get_config(cfg_sect,"vsync",0);
420 29 Throttlefps = zc_get_config(cfg_sect,"throttlefps",1)!=0;
421 29 TransLayers = zc_get_config(cfg_sect,"translayers",1)!=0;
422 29 SnapshotFormat = zc_get_config(cfg_sect,"snapshot_format",3);
423 29 NameEntryMode = zc_get_config(cfg_sect,"name_entry_mode",0);
424 #ifdef __EMSCRIPTEN__
425 if (em_is_mobile()) NameEntryMode = 2;
426 #endif
427 29 ShowFPS = zc_get_config(cfg_sect,"showfps",0)!=0;
428 29 NESquit = zc_get_config(cfg_sect,"fastquit",0)!=0;
429 29 ClickToFreeze = zc_get_config(cfg_sect,"clicktofreeze",1)!=0;
430 29 title_version = zc_get_config(cfg_sect,"title",2);
431 29 abc_patternmatch = zc_get_config(cfg_sect, "lister_pattern_matching", 1);
432 29 pause_in_background = zc_get_config(cfg_sect, "pause_in_background", 0);
433
434 //default - scale x2, 640 x 480
435 29 window_width = resx = zc_get_config(cfg_sect,"window_width",640);
436 29 window_height = resy = zc_get_config(cfg_sect,"window_height",480);
437 29 SaveDragResize = zc_get_config(cfg_sect,"save_drag_resize",0)!=0;
438 29 DragAspect = zc_get_config(cfg_sect,"drag_aspect",0)!=0;
439 29 SaveWinPos = zc_get_config(cfg_sect,"save_window_position",0)!=0;
440
441 29 loadlast = zc_get_config(cfg_sect,"load_last",0);
442
443 29 fullscreen = zc_get_config(cfg_sect,"fullscreen",0);
444
445 29 zc_color_depth = (byte) zc_get_config(cfg_sect,"color_depth",8);
446
447 29 forceExit = (byte) zc_get_config(cfg_sect,"force_exit",0);
448 29 info_opacity = zc_get_config("zc","debug_info_opacity",255);
449 #ifdef _WIN32
450 zasm_debugger = (byte) zc_get_config("CONSOLE","print_ZASM",0);
451 zscript_debugger = (byte) zc_get_config("CONSOLE","ZScript_Debugger",0);
452 //use_win7_keyboard_fix = (byte) zc_get_config(cfg_sect,"use_win7_key_fix",0);
453 use_win32_proc = (byte) zc_get_config(cfg_sect,"zc_win_proc_fix",0); //buggy
454
455 // This one's for Aero
456 use_dwm_flush = (byte) zc_get_config("zeldadx","use_dwm_flush",0);
457
458 // And this one fixes patches unloading on some MIDI setups
459 midi_patch_fix = (byte) zc_get_config("zeldadx","midi_patch_fix",1);
460 monochrome_console = (byte) zc_get_config("CONSOLE","monochrome_debuggers",0);
461 #else //UNIX
462 29 zasm_debugger = (byte) zc_get_config("CONSOLE","print_ZASM",0);
463 29 zscript_debugger = (byte) zc_get_config("CONSOLE","ZScript_Debugger",0);
464 29 monochrome_console = (byte) zc_get_config("CONSOLE","monochrome_debuggers",0);
465 #endif
466 29 clearConsoleOnLoad = zc_get_config("CONSOLE","clear_console_on_load",1)!=0;
467
468 29 char const* default_path = "";
469 29 strcpy(qstdir,zc_get_config(cfg_sect,qst_dir_name,default_path));
470
471
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
29 if(strlen(qstdir)==0)
472 {
473 29 getcwd(qstdir,2048);
474 29 fix_filename_case(qstdir);
475 29 fix_filename_slashes(qstdir);
476 29 put_backslash(qstdir);
477 29 }
478 else
479 {
480 chop_path(qstdir);
481 }
482
483 29 strcpy(qstpath,qstdir); //qstpath is the local (for this run of ZC) quest path, qstdir is the universal quest dir.
484 29 ss_enable = zc_get_config(cfg_sect,"ss_enable",1) ? 1 : 0;
485 29 ss_after = vbound(zc_get_config(cfg_sect,"ss_after",14), 0, 14);
486 29 ss_speed = vbound(zc_get_config(cfg_sect,"ss_speed",2), 0, 6);
487 29 ss_density = vbound(zc_get_config(cfg_sect,"ss_density",3), 0, 6);
488 29 heart_beep = zc_get_config(cfg_sect,"heart_beep",1)!=0;
489 //gui_colorset = zc_get_config(cfg_sect,"gui_colorset",0);
490 29 sfxdat = zc_get_config(cfg_sect,"use_sfx_dat",1);
491 29 fullscreen = zc_get_config(cfg_sect,"fullscreen",0);
492 29 use_save_indicator = zc_get_config(cfg_sect,"save_indicator",0);
493 29 zc_192b163_warp_compatibility = zc_get_config(cfg_sect,"zc_192b163_warp_compatibility",0);
494 29 }
495
496 void save_control_configs(bool kb)
497 {
498 if(kb)
499 {
500 zc_set_config(ctrl_sect,"key_cheatmod_a1",cheat_modifier_keys[0]);
501 zc_set_config(ctrl_sect,"key_cheatmod_a2",cheat_modifier_keys[1]);
502 zc_set_config(ctrl_sect,"key_cheatmod_b1",cheat_modifier_keys[2]);
503 zc_set_config(ctrl_sect,"key_cheatmod_b2",cheat_modifier_keys[3]);
504
505 if (!replay_is_replaying())
506 {
507 zc_set_config(ctrl_sect,"key_a",Akey);
508 zc_set_config(ctrl_sect,"key_b",Bkey);
509 zc_set_config(ctrl_sect,"key_s",Skey);
510 zc_set_config(ctrl_sect,"key_l",Lkey);
511 zc_set_config(ctrl_sect,"key_r",Rkey);
512 zc_set_config(ctrl_sect,"key_p",Pkey);
513 zc_set_config(ctrl_sect,"key_ex1",Exkey1);
514 zc_set_config(ctrl_sect,"key_ex2",Exkey2);
515 zc_set_config(ctrl_sect,"key_ex3",Exkey3);
516 zc_set_config(ctrl_sect,"key_ex4",Exkey4);
517 zc_set_config(ctrl_sect,"key_up", DUkey);
518 zc_set_config(ctrl_sect,"key_down", DDkey);
519 zc_set_config(ctrl_sect,"key_left", DLkey);
520 zc_set_config(ctrl_sect,"key_right",DRkey);
521 }
522 }
523 else
524 {
525 zc_set_config(ctrl_sect,"joystick_index",joystick_index);
526 zc_set_config(ctrl_sect,"js_stick_1_x_stick",js_stick_1_x_stick);
527 zc_set_config(ctrl_sect,"js_stick_1_x_axis",js_stick_1_x_axis);
528 zc_set_config(ctrl_sect,"js_stick_1_x_offset",js_stick_1_x_offset ? 1 : 0);
529 zc_set_config(ctrl_sect,"js_stick_1_y_stick",js_stick_1_y_stick);
530 zc_set_config(ctrl_sect,"js_stick_1_y_axis",js_stick_1_y_axis);
531 zc_set_config(ctrl_sect,"js_stick_1_y_offset",js_stick_1_y_offset ? 1 : 0);
532 zc_set_config(ctrl_sect,"js_stick_2_x_stick",js_stick_2_x_stick);
533 zc_set_config(ctrl_sect,"js_stick_2_x_axis",js_stick_2_x_axis);
534 zc_set_config(ctrl_sect,"js_stick_2_x_offset",js_stick_2_x_offset ? 1 : 0);
535 zc_set_config(ctrl_sect,"js_stick_2_y_stick",js_stick_2_y_stick);
536 zc_set_config(ctrl_sect,"js_stick_2_y_axis",js_stick_2_y_axis);
537 zc_set_config(ctrl_sect,"js_stick_2_y_offset",js_stick_2_y_offset ? 1 : 0);
538 zc_set_config(ctrl_sect,"analog_movement",analog_movement);
539
540 zc_set_config(ctrl_sect,"btn_a",Abtn);
541 zc_set_config(ctrl_sect,"btn_b",Bbtn);
542 zc_set_config(ctrl_sect,"btn_s",Sbtn);
543 zc_set_config(ctrl_sect,"btn_m",Mbtn);
544 zc_set_config(ctrl_sect,"btn_l",Lbtn);
545 zc_set_config(ctrl_sect,"btn_r",Rbtn);
546 zc_set_config(ctrl_sect,"btn_p",Pbtn);
547 zc_set_config(ctrl_sect,"btn_ex1",Exbtn1);
548 zc_set_config(ctrl_sect,"btn_ex2",Exbtn2);
549 zc_set_config(ctrl_sect,"btn_ex3",Exbtn3);
550 zc_set_config(ctrl_sect,"btn_ex4",Exbtn4);
551
552 zc_set_config(ctrl_sect,"btn_up",DUbtn);
553 zc_set_config(ctrl_sect,"btn_down",DDbtn);
554 zc_set_config(ctrl_sect,"btn_left",DLbtn);
555 zc_set_config(ctrl_sect,"btn_right",DRbtn);
556 }
557 }
558
559 void save_cheatkeys()
560 {
561 char buf[256];
562 for(size_t q = 1; q < Cheat::Last; ++q)
563 {
564 if(!bindable_cheat((Cheat)q)) continue;
565 std::string cheatname = cheat_to_string((Cheat)q);
566 util::lowerstr(cheatname);
567 sprintf(buf, "key_cheat_%s_main", cheatname.c_str());
568 zc_set_config(ctrl_sect,buf,cheatkeys[q][0]);
569 sprintf(buf, "key_cheat_%s_alt", cheatname.c_str());
570 if(cheatkeys[q][1])
571 zc_set_config(ctrl_sect,buf,cheatkeys[q][1]);
572 else zc_set_config(ctrl_sect,buf,(char*)nullptr);
573 }
574 }
575
576 void save_game_configs()
577 {
578 packfile_password("");
579
580 zc_set_config("ZCMODULE",qst_module_name,moduledata.module_name);
581
582 if (all_get_display() && !all_get_fullscreen_flag()&& SaveWinPos)
583 {
584 int o_window_x, o_window_y;
585 al_get_window_position(all_get_display(), &o_window_x, &o_window_y);
586 zc_set_config(cfg_sect,"window_x",o_window_x);
587 zc_set_config(cfg_sect,"window_y",o_window_y);
588 }
589
590 if (all_get_display() && !all_get_fullscreen_flag() && SaveDragResize)
591 {
592 double monitor_scale = zc_get_monitor_scale();
593 window_width = al_get_display_width(all_get_display()) / monitor_scale;
594 window_height = al_get_display_height(all_get_display()) / monitor_scale;
595 zc_set_config(cfg_sect,"window_width",window_width);
596 zc_set_config(cfg_sect,"window_height",window_height);
597 }
598
599 zc_set_config(cfg_sect,"load_last",loadlast);
600 chop_path(qstdir);
601 zc_set_config(cfg_sect,qst_dir_name,qstdir);
602 zc_set_config("SAVEFILE","save_filename",save_file_name);
603 zc_set_config(cfg_sect,"use_sfx_dat",sfxdat);
604
605 flush_config_file();
606 #ifdef __EMSCRIPTEN__
607 em_sync_fs();
608 #endif
609 }
610
611 //----------------------------------------------------------------
612
613 // Timers
614
615 28502 void fps_callback()
616 {
617 28502 lastfps=framecnt;
618 28502 dword tempsecs = fps_secs;
619 28502 ++tempsecs;
620 //avgfps=((long double)avgfps*fps_secs+lastfps)/(++fps_secs); // DJGPP doesn't like this
621 28502 avgfps=((long double)avgfps*fps_secs+lastfps)/(tempsecs);
622 28502 ++fps_secs;
623 28502 framecnt=0;
624 28502 }
625
626 END_OF_FUNCTION(fps_callback)
627
628 29 int32_t Z_init_timers()
629 {
630 static bool didit = false;
631 const static char *err_str = "Couldn't allocate timer";
632 29 err_str = err_str; //Unused variable warning
633
634
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
29 if(didit)
635 return 1;
636
637 29 didit = true;
638
639 LOCK_VARIABLE(lastfps);
640 LOCK_VARIABLE(framecnt);
641 LOCK_FUNCTION(fps_callback);
642
643
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if(install_int_ex(fps_callback,SECS_TO_TIMER(1)))
644 return 0;
645
646 29 return 1;
647 29 }
648
649 void Z_remove_timers()
650 {
651 remove_int(fps_callback);
652 }
653
654 //----------------------------------------------------------------
655
656 void go()
657 {
658 scare_mouse();
659 blit(screen,tmp_scr,scrx,scry,0,0,screen->w,screen->h);
660 unscare_mouse();
661 }
662
663 void comeback()
664 {
665 scare_mouse();
666 blit(tmp_scr,screen,0,0,scrx,scry,screen->w,screen->h);
667 unscare_mouse();
668 }
669
670 void dump_pal(BITMAP *dest)
671 {
672 for(int32_t i=0; i<256; i++)
673 rectfill(dest,(i&63)<<2,(i&0xFC0)>>4,((i&63)<<2)+3,((i&0xFC0)>>4)+3,i);
674 }
675
676 //----------------------------------------------------------------
677
678 //Handles converting the mouse sprite from the .dat file
679 29 void load_mouse()
680 {
681 29 system_pal();
682 29 scare_mouse();
683 29 set_mouse_sprite(NULL);
684 29 int32_t sz = vbound(int32_t(16*(zc_get_config("zeldadx","cursor_scale_large",1.5))),16,80);
685
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 29 times.
145 for(int32_t j = 0; j < 4; ++j)
686 {
687 116 BITMAP* tmpbmp = create_bitmap_ex(8,16,16);
688 116 BITMAP* subbmp = create_bitmap_ex(8,16,16);
689
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(zcmouse[j])
690 destroy_bitmap(zcmouse[j]);
691 116 zcmouse[j] = create_bitmap_ex(8,sz,sz);
692 116 clear_bitmap(zcmouse[j]);
693 116 clear_bitmap(tmpbmp);
694 116 clear_bitmap(subbmp);
695 116 blit((BITMAP*)datafile[BMP_MOUSE].dat,tmpbmp,1,j*17+1,0,0,16,16);
696
2/2
✓ Branch 0 taken 1856 times.
✓ Branch 1 taken 116 times.
1972 for(int32_t x = 0; x < 16; ++x)
697 {
698
2/2
✓ Branch 0 taken 29696 times.
✓ Branch 1 taken 1856 times.
31552 for(int32_t y = 0; y < 16; ++y)
699 {
700 29696 int32_t color = getpixel(tmpbmp, x, y);
701
5/5
✓ Branch 0 taken 27318 times.
✓ Branch 1 taken 551 times.
✓ Branch 2 taken 638 times.
✓ Branch 3 taken 667 times.
✓ Branch 4 taken 522 times.
29696 switch(color)
702 {
703 case dvc(1):
704 551 color = jwin_pal[jcCURSORMISC];
705 551 break;
706 case dvc(2):
707 638 color = jwin_pal[jcCURSOROUTLINE];
708 638 break;
709 case dvc(3):
710 667 color = jwin_pal[jcCURSORLIGHT];
711 667 break;
712 case dvc(5):
713 522 color = jwin_pal[jcCURSORDARK];
714 522 break;
715 }
716 29696 putpixel(subbmp, x, y, color);
717 29696 }
718 1856 }
719
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(sz!=16)
720 116 stretch_blit(subbmp, zcmouse[j], 0, 0, 16, 16, 0, 0, sz, sz);
721 else
722 blit(subbmp, zcmouse[j], 0, 0, 0, 0, 16, 16);
723 116 destroy_bitmap(tmpbmp);
724 116 destroy_bitmap(subbmp);
725 116 }
726 29 set_mouse_sprite(zcmouse[0]);
727
728 // Must attempt to show cursor for allegro 5 to render it with the associated palette.
729 29 zc_set_palette(*hw_palette);
730 29 show_mouse(screen);
731 29 show_mouse(NULL);
732
733 29 unscare_mouse();
734 29 game_pal();
735 29 }
736
737 // sets the video mode and initializes the palette and mouse sprite
738 29 bool game_vid_mode(int32_t mode,int32_t wait)
739 {
740
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
29 if(set_gfx_mode(mode,resx,resy,0,0)!=0)
741 {
742 return false;
743 }
744
745 29 scrx = (resx-320)>>1;
746 29 scry = (resy-240)>>1;
747
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 29 times.
145 for(int32_t q = 0; q < 4; ++q)
748 116 zcmouse[q] = NULL;
749 29 load_mouse();
750 29 set_mouse_sprite(zcmouse[0]);
751
752
2/2
✓ Branch 0 taken 464 times.
✓ Branch 1 taken 29 times.
493 for(int32_t i=240; i<256; i++)
753 464 RAMpal[i]=((RGB*)datafile[PAL_GUI].dat)[i];
754
755 29 zc_set_palette(RAMpal);
756 29 clear_to_color(screen,BLACK);
757
758 29 rest(wait);
759 29 return true;
760 29 }
761
762 5 void null_quest()
763 {
764 char qstdat_string[2048];
765 5 strcpy(qstdat_string,moduledata.datafiles[qst_dat]);
766 5 strcat(qstdat_string,"#NESQST_NEW_QST");
767
768 #ifdef __EMSCRIPTEN__
769 // The quest template data file is not included because it's really big and isn't really needed
770 // for the player, except to initialize some graphics. Those same graphics exist in this quest file,
771 // which is much smaller.
772 strcpy(qstdat_string, "modules/classic/title_gfx.dat");
773 #endif
774
775 5 byte skip_flags[4] = { 0 };
776
777 5 loadquest(qstdat_string,&QHeader,&QMisc,tunes+ZC_MIDI_COUNT,false,true,true,true,skip_flags,0,false);
778 5 }
779
780 5 void init_NES_mode()
781 {
782 /*
783 // qst.dat may not load correctly without this...
784 QHeader.templatepath[0]='\0';
785
786 if(!init_colordata(true, &QHeader, &QMisc))
787 {
788 return;
789 }
790
791 loadfullpal();
792 init_tiles(false, &QHeader);
793 */
794 5 null_quest();
795 5 }
796
797 //----------------------------------------------------------------
798
799 qword trianglelines[16]=
800 {
801 0x0000000000000000ULL,
802 0xFD00000000000000ULL,
803 0xFDFD000000000000ULL,
804 0xFDFDFD0000000000ULL,
805 0xFDFDFDFD00000000ULL,
806 0xFDFDFDFDFD000000ULL,
807 0xFDFDFDFDFDFD0000ULL,
808 0xFDFDFDFDFDFDFD00ULL,
809 0xFDFDFDFDFDFDFDFDULL,
810 0x00FDFDFDFDFDFDFDULL,
811 0x0000FDFDFDFDFDFDULL,
812 0x000000FDFDFDFDFDULL,
813 0x00000000FDFDFDFDULL,
814 0x0000000000FDFDFDULL,
815 0x000000000000FDFDULL,
816 0x00000000000000FDULL,
817 };
818
819 word screen_triangles[28][32];
820 /*
821 qword triangles[4][16]= //[direction][value]
822 {
823 {
824 0x00000000, 0x10000000, 0x21000000, 0x32100000, 0x43210000, 0x54321000, 0x65432100, 0x76543210, 0x87654321, 0x88765432, 0x88876543, 0x88887654, 0x88888765, 0x88888876, 0x88888887, 0x88888888
825 },
826 {
827 0x00000000, 0xF0000000, 0xEF000000, 0xFDF00000, 0xCFDF0000, 0xBCFDF000, 0xABCFDF00, 0x9ABCFDF0, 0x89ABCFDF, 0x889ABCFD, 0x8889ABCD, 0x88889ABC, 0x888889AB, 0x8888889A, 0x88888889, 0x88888888
828 },
829 {
830 0x00000000, 0x00000001, 0x00000012, 0x00000123, 0x00001234, 0x00012345, 0x00123456, 0x01234567, 0x12345678, 0x23456788, 0x34567888, 0x45678888, 0x56788888, 0x67888888, 0x78888888, 0x88888888
831 },
832 {
833 0x00000000, 0x0000000F, 0x000000FE, 0x00000FED, 0x0000FEDC, 0x000FEDCB, 0x00FEDCBA, 0x0FEDCBA9, 0xFEDCBA98, 0xEDCBA988, 0xDCBA9888, 0xCBA98888, 0xBA988888, 0xA9888888, 0x98888888, 0x88888888
834 }
835 };
836 */
837
838
839 /*
840 byte triangles[4][16][8]= //[direction][value][line]
841 {
842 {
843 {
844 0, 0, 0, 0, 0, 0, 0, 0
845 },
846 {
847 1, 0, 0, 0, 0, 0, 0, 0
848 },
849 {
850 2, 1, 0, 0, 0, 0, 0, 0
851 },
852 {
853 3, 2, 1, 0, 0, 0, 0, 0
854 },
855 {
856 4, 3, 2, 1, 0, 0, 0, 0
857 },
858 {
859 5, 4, 3, 2, 1, 0, 0, 0
860 },
861 {
862 6, 5, 4, 3, 2, 1, 0, 0
863 },
864 {
865 7, 6, 5, 4, 3, 2, 1, 0
866 },
867 {
868 8, 7, 6, 5, 4, 3, 2, 1
869 },
870 {
871 8, 8, 7, 6, 5, 4, 3, 2
872 },
873 {
874 8, 8, 8, 7, 6, 5, 4, 3
875 },
876 {
877 8, 8, 8, 8, 7, 6, 5, 4
878 },
879 {
880 8, 8, 8, 8, 8, 7, 6, 5
881 },
882 {
883 8, 8, 8, 8, 8, 8, 7, 6
884 },
885 {
886 8, 8, 8, 8, 8, 8, 8, 7
887 },
888 {
889 8, 8, 8, 8, 8, 8, 8, 8
890 }
891 },
892 {
893 {
894 0, 0, 0, 0, 0, 0, 0, 0
895 },
896 {
897 15, 0, 0, 0, 0, 0, 0, 0
898 },
899 {
900 14, 15, 0, 0, 0, 0, 0, 0
901 },
902 {
903 13, 14, 15, 0, 0, 0, 0, 0
904 },
905 {
906 12, 13, 14, 15, 0, 0, 0, 0
907 },
908 {
909 11, 12, 13, 14, 15, 0, 0, 0
910 },
911 {
912 10, 11, 12, 13, 14, 15, 0, 0
913 },
914 {
915 9, 10, 11, 12, 13, 14, 15, 0
916 },
917 {
918 8, 9, 10, 11, 12, 13, 14, 15
919 },
920 {
921 8, 8, 9, 10, 11, 12, 13, 14
922 },
923 {
924 8, 8, 8, 9, 10, 11, 12, 13
925 },
926 {
927 8, 8, 8, 8, 9, 10, 11, 12
928 },
929 {
930 8, 8, 8, 8, 8, 9, 10, 11
931 },
932 {
933 8, 8, 8, 8, 8, 8, 9, 10
934 },
935 {
936 8, 8, 8, 8, 8, 8, 8, 9
937 },
938 {
939 8, 8, 8, 8, 8, 8, 8, 8
940 }
941 },
942 {
943 {
944 0, 0, 0, 0, 0, 0, 0, 0
945 },
946 {
947 0, 0, 0, 0, 0, 0, 0, 1
948 },
949 {
950 0, 0, 0, 0, 0, 0, 1, 2
951 },
952 {
953 0, 0, 0, 0, 0, 1, 2, 3
954 },
955 {
956 0, 0, 0, 0, 1, 2, 3, 4
957 },
958 {
959 0, 0, 0, 1, 2, 3, 4, 5
960 },
961 {
962 0, 0, 1, 2, 3, 4, 5, 6
963 },
964 {
965 0, 1, 2, 3, 4, 5, 6, 7
966 },
967 {
968 1, 2, 3, 4, 5, 6, 7, 8
969 },
970 {
971 2, 3, 4, 5, 6, 7, 8, 8
972 },
973 {
974 3, 4, 5, 6, 7, 8, 8, 8
975 },
976 {
977 4, 5, 6, 7, 8, 8, 8, 8
978 },
979 {
980 5, 6, 7, 8, 8, 8, 8, 8
981 },
982 {
983 6, 7, 8, 8, 8, 8, 8, 8
984 },
985 {
986 7, 8, 8, 8, 8, 8, 8, 8
987 },
988 {
989 8, 8, 8, 8, 8, 8, 8, 8
990 }
991 },
992 {
993 {
994 0, 0, 0, 0, 0, 0, 0, 0
995 },
996 {
997 0, 0, 0, 0, 0, 0, 0, 15
998 },
999 {
1000 0, 0, 0, 0, 0, 0, 15, 14
1001 },
1002 {
1003 0, 0, 0, 0, 0, 15, 14, 13
1004 },
1005 {
1006 0, 0, 0, 0, 15, 14, 13, 12
1007 },
1008 {
1009 0, 0, 0, 15, 14, 13, 12, 11
1010 },
1011 {
1012 0, 0, 15, 14, 13, 12, 11, 10
1013 },
1014 {
1015 0, 15, 14, 13, 12, 11, 10, 9
1016 },
1017 {
1018 15, 14, 13, 12, 11, 10, 9, 8
1019 },
1020 {
1021 14, 13, 12, 11, 10, 9, 8, 8
1022 },
1023 {
1024 13, 12, 11, 10, 9, 8, 8, 8
1025 },
1026 {
1027 12, 11, 10, 9, 8, 8, 8, 8
1028 },
1029 {
1030 11, 10, 9, 8, 8, 8, 8, 8
1031 },
1032 {
1033 10, 9, 8, 8, 8, 8, 8, 8
1034 },
1035 {
1036 9, 8, 8, 8, 8, 8, 8, 8
1037 },
1038 {
1039 8, 8, 8, 8, 8, 8, 8, 8
1040 }
1041 }
1042 };
1043 */
1044
1045
1046
1047 /*
1048 for (int32_t blockrow=0; blockrow<30; ++i)
1049 {
1050 for (int32_t linerow=0; linerow<8; ++i)
1051 {
1052 qword *triangleline=(qword*)(tmp_scr->line[(blockrow*8+linerow)]);
1053 for (int32_t blockcolumn=0; blockcolumn<40; ++i)
1054 {
1055 triangleline=triangles[0][screen_triangles[blockrow][blockcolumn]][linerow];
1056 ++triangleline;
1057 }
1058 }
1059 }
1060 */
1061
1062 // the ULL suffixes are to prevent this warning:
1063 // warning: integer constant is too large for "int32_t" type
1064
1065 qword triangles[4][16][8]= //[direction][value][line]
1066 {
1067 {
1068 {
1069 0x0000000000000000ULL,
1070 0x0000000000000000ULL,
1071 0x0000000000000000ULL,
1072 0x0000000000000000ULL,
1073 0x0000000000000000ULL,
1074 0x0000000000000000ULL,
1075 0x0000000000000000ULL,
1076 0x0000000000000000ULL
1077 },
1078 {
1079 0xFD00000000000000ULL,
1080 0x0000000000000000ULL,
1081 0x0000000000000000ULL,
1082 0x0000000000000000ULL,
1083 0x0000000000000000ULL,
1084 0x0000000000000000ULL,
1085 0x0000000000000000ULL,
1086 0x0000000000000000ULL
1087 },
1088 {
1089 0xFDFD000000000000ULL,
1090 0xFD00000000000000ULL,
1091 0x0000000000000000ULL,
1092 0x0000000000000000ULL,
1093 0x0000000000000000ULL,
1094 0x0000000000000000ULL,
1095 0x0000000000000000ULL,
1096 0x0000000000000000ULL
1097 },
1098 {
1099 0xFDFDFD0000000000ULL,
1100 0xFDFD000000000000ULL,
1101 0xFD00000000000000ULL,
1102 0x0000000000000000ULL,
1103 0x0000000000000000ULL,
1104 0x0000000000000000ULL,
1105 0x0000000000000000ULL,
1106 0x0000000000000000ULL
1107 },
1108 {
1109 0xFDFDFDFD00000000ULL,
1110 0xFDFDFD0000000000ULL,
1111 0xFDFD000000000000ULL,
1112 0xFD00000000000000ULL,
1113 0x0000000000000000ULL,
1114 0x0000000000000000ULL,
1115 0x0000000000000000ULL,
1116 0x0000000000000000ULL
1117 },
1118 {
1119 0xFDFDFDFDFD000000ULL,
1120 0xFDFDFDFD00000000ULL,
1121 0xFDFDFD0000000000ULL,
1122 0xFDFD000000000000ULL,
1123 0xFD00000000000000ULL,
1124 0x0000000000000000ULL,
1125 0x0000000000000000ULL,
1126 0x0000000000000000ULL
1127 },
1128 {
1129 0xFDFDFDFDFDFD0000ULL,
1130 0xFDFDFDFDFD000000ULL,
1131 0xFDFDFDFD00000000ULL,
1132 0xFDFDFD0000000000ULL,
1133 0xFDFD000000000000ULL,
1134 0xFD00000000000000ULL,
1135 0x0000000000000000ULL,
1136 0x0000000000000000ULL
1137 },
1138 {
1139 0xFDFDFDFDFDFDFD00ULL,
1140 0xFDFDFDFDFDFD0000ULL,
1141 0xFDFDFDFDFD000000ULL,
1142 0xFDFDFDFD00000000ULL,
1143 0xFDFDFD0000000000ULL,
1144 0xFDFD000000000000ULL,
1145 0xFD00000000000000ULL,
1146 0x0000000000000000ULL
1147 },
1148 {
1149 0xFDFDFDFDFDFDFDFDULL,
1150 0xFDFDFDFDFDFDFD00ULL,
1151 0xFDFDFDFDFDFD0000ULL,
1152 0xFDFDFDFDFD000000ULL,
1153 0xFDFDFDFD00000000ULL,
1154 0xFDFDFD0000000000ULL,
1155 0xFDFD000000000000ULL,
1156 0xFD00000000000000ULL
1157 },
1158 {
1159 0xFDFDFDFDFDFDFDFDULL,
1160 0xFDFDFDFDFDFDFDFDULL,
1161 0xFDFDFDFDFDFDFD00ULL,
1162 0xFDFDFDFDFDFD0000ULL,
1163 0xFDFDFDFDFD000000ULL,
1164 0xFDFDFDFD00000000ULL,
1165 0xFDFDFD0000000000ULL,
1166 0xFDFD000000000000ULL
1167 },
1168 {
1169 0xFDFDFDFDFDFDFDFDULL,
1170 0xFDFDFDFDFDFDFDFDULL,
1171 0xFDFDFDFDFDFDFDFDULL,
1172 0xFDFDFDFDFDFDFD00ULL,
1173 0xFDFDFDFDFDFD0000ULL,
1174 0xFDFDFDFDFD000000ULL,
1175 0xFDFDFDFD00000000ULL,
1176 0xFDFDFD0000000000ULL
1177 },
1178 {
1179 0xFDFDFDFDFDFDFDFDULL,
1180 0xFDFDFDFDFDFDFDFDULL,
1181 0xFDFDFDFDFDFDFDFDULL,
1182 0xFDFDFDFDFDFDFDFDULL,
1183 0xFDFDFDFDFDFDFD00ULL,
1184 0xFDFDFDFDFDFD0000ULL,
1185 0xFDFDFDFDFD000000ULL,
1186 0xFDFDFDFD00000000ULL
1187 },
1188 {
1189 0xFDFDFDFDFDFDFDFDULL,
1190 0xFDFDFDFDFDFDFDFDULL,
1191 0xFDFDFDFDFDFDFDFDULL,
1192 0xFDFDFDFDFDFDFDFDULL,
1193 0xFDFDFDFDFDFDFDFDULL,
1194 0xFDFDFDFDFDFDFD00ULL,
1195 0xFDFDFDFDFDFD0000ULL,
1196 0xFDFDFDFDFD000000ULL
1197 },
1198 {
1199 0xFDFDFDFDFDFDFDFDULL,
1200 0xFDFDFDFDFDFDFDFDULL,
1201 0xFDFDFDFDFDFDFDFDULL,
1202 0xFDFDFDFDFDFDFDFDULL,
1203 0xFDFDFDFDFDFDFDFDULL,
1204 0xFDFDFDFDFDFDFDFDULL,
1205 0xFDFDFDFDFDFDFD00ULL,
1206 0xFDFDFDFDFDFD0000ULL
1207 },
1208 {
1209 0xFDFDFDFDFDFDFDFDULL,
1210 0xFDFDFDFDFDFDFDFDULL,
1211 0xFDFDFDFDFDFDFDFDULL,
1212 0xFDFDFDFDFDFDFDFDULL,
1213 0xFDFDFDFDFDFDFDFDULL,
1214 0xFDFDFDFDFDFDFDFDULL,
1215 0xFDFDFDFDFDFDFDFDULL,
1216 0xFDFDFDFDFDFDFD00ULL
1217 },
1218 {
1219 0xFDFDFDFDFDFDFDFDULL,
1220 0xFDFDFDFDFDFDFDFDULL,
1221 0xFDFDFDFDFDFDFDFDULL,
1222 0xFDFDFDFDFDFDFDFDULL,
1223 0xFDFDFDFDFDFDFDFDULL,
1224 0xFDFDFDFDFDFDFDFDULL,
1225 0xFDFDFDFDFDFDFDFDULL,
1226 0xFDFDFDFDFDFDFDFDULL
1227 }
1228 },
1229 {
1230 {
1231 0x0000000000000000ULL,
1232 0x0000000000000000ULL,
1233 0x0000000000000000ULL,
1234 0x0000000000000000ULL,
1235 0x0000000000000000ULL,
1236 0x0000000000000000ULL,
1237 0x0000000000000000ULL,
1238 0x0000000000000000ULL
1239 },
1240 {
1241 0x00000000000000FDULL,
1242 0x0000000000000000ULL,
1243 0x0000000000000000ULL,
1244 0x0000000000000000ULL,
1245 0x0000000000000000ULL,
1246 0x0000000000000000ULL,
1247 0x0000000000000000ULL,
1248 0x0000000000000000ULL
1249 },
1250 {
1251 0x000000000000FDFDULL,
1252 0x00000000000000FDULL,
1253 0x0000000000000000ULL,
1254 0x0000000000000000ULL,
1255 0x0000000000000000ULL,
1256 0x0000000000000000ULL,
1257 0x0000000000000000ULL,
1258 0x0000000000000000ULL
1259 },
1260 {
1261 0x0000000000FDFDFDULL,
1262 0x000000000000FDFDULL,
1263 0x00000000000000FDULL,
1264 0x0000000000000000ULL,
1265 0x0000000000000000ULL,
1266 0x0000000000000000ULL,
1267 0x0000000000000000ULL,
1268 0x0000000000000000ULL
1269 },
1270 {
1271 0x00000000FDFDFDFDULL,
1272 0x0000000000FDFDFDULL,
1273 0x000000000000FDFDULL,
1274 0x00000000000000FDULL,
1275 0x0000000000000000ULL,
1276 0x0000000000000000ULL,
1277 0x0000000000000000ULL,
1278 0x0000000000000000ULL
1279 },
1280 {
1281 0x000000FDFDFDFDFDULL,
1282 0x00000000FDFDFDFDULL,
1283 0x0000000000FDFDFDULL,
1284 0x000000000000FDFDULL,
1285 0x00000000000000FDULL,
1286 0x0000000000000000ULL,
1287 0x0000000000000000ULL,
1288 0x0000000000000000ULL
1289 },
1290 {
1291 0x0000FDFDFDFDFDFDULL,
1292 0x000000FDFDFDFDFDULL,
1293 0x00000000FDFDFDFDULL,
1294 0x0000000000FDFDFDULL,
1295 0x000000000000FDFDULL,
1296 0x00000000000000FDULL,
1297 0x0000000000000000ULL,
1298 0x0000000000000000ULL
1299 },
1300 {
1301 0x00FDFDFDFDFDFDFDULL,
1302 0x0000FDFDFDFDFDFDULL,
1303 0x000000FDFDFDFDFDULL,
1304 0x00000000FDFDFDFDULL,
1305 0x0000000000FDFDFDULL,
1306 0x000000000000FDFDULL,
1307 0x00000000000000FDULL,
1308 0x0000000000000000ULL
1309 },
1310 {
1311 0xFDFDFDFDFDFDFDFDULL,
1312 0x00FDFDFDFDFDFDFDULL,
1313 0x0000FDFDFDFDFDFDULL,
1314 0x000000FDFDFDFDFDULL,
1315 0x00000000FDFDFDFDULL,
1316 0x0000000000FDFDFDULL,
1317 0x000000000000FDFDULL,
1318 0x00000000000000FDULL
1319 },
1320 {
1321 0xFDFDFDFDFDFDFDFDULL,
1322 0xFDFDFDFDFDFDFDFDULL,
1323 0x00FDFDFDFDFDFDFDULL,
1324 0x0000FDFDFDFDFDFDULL,
1325 0x000000FDFDFDFDFDULL,
1326 0x00000000FDFDFDFDULL,
1327 0x0000000000FDFDFDULL,
1328 0x000000000000FDFDULL
1329 },
1330 {
1331 0xFDFDFDFDFDFDFDFDULL,
1332 0xFDFDFDFDFDFDFDFDULL,
1333 0xFDFDFDFDFDFDFDFDULL,
1334 0x00FDFDFDFDFDFDFDULL,
1335 0x0000FDFDFDFDFDFDULL,
1336 0x000000FDFDFDFDFDULL,
1337 0x00000000FDFDFDFDULL,
1338 0x0000000000FDFDFDULL
1339 },
1340 {
1341 0xFDFDFDFDFDFDFDFDULL,
1342 0xFDFDFDFDFDFDFDFDULL,
1343 0xFDFDFDFDFDFDFDFDULL,
1344 0xFDFDFDFDFDFDFDFDULL,
1345 0x00FDFDFDFDFDFDFDULL,
1346 0x0000FDFDFDFDFDFDULL,
1347 0x000000FDFDFDFDFDULL,
1348 0x00000000FDFDFDFDULL
1349 },
1350 {
1351 0xFDFDFDFDFDFDFDFDULL,
1352 0xFDFDFDFDFDFDFDFDULL,
1353 0xFDFDFDFDFDFDFDFDULL,
1354 0xFDFDFDFDFDFDFDFDULL,
1355 0xFDFDFDFDFDFDFDFDULL,
1356 0x00FDFDFDFDFDFDFDULL,
1357 0x0000FDFDFDFDFDFDULL,
1358 0x000000FDFDFDFDFDULL
1359 },
1360 {
1361 0xFDFDFDFDFDFDFDFDULL,
1362 0xFDFDFDFDFDFDFDFDULL,
1363 0xFDFDFDFDFDFDFDFDULL,
1364 0xFDFDFDFDFDFDFDFDULL,
1365 0xFDFDFDFDFDFDFDFDULL,
1366 0xFDFDFDFDFDFDFDFDULL,
1367 0x00FDFDFDFDFDFDFDULL,
1368 0x0000FDFDFDFDFDFDULL
1369 },
1370 {
1371 0xFDFDFDFDFDFDFDFDULL,
1372 0xFDFDFDFDFDFDFDFDULL,
1373 0xFDFDFDFDFDFDFDFDULL,
1374 0xFDFDFDFDFDFDFDFDULL,
1375 0xFDFDFDFDFDFDFDFDULL,
1376 0xFDFDFDFDFDFDFDFDULL,
1377 0xFDFDFDFDFDFDFDFDULL,
1378 0x00FDFDFDFDFDFDFDULL
1379 },
1380 {
1381 0xFDFDFDFDFDFDFDFDULL,
1382 0xFDFDFDFDFDFDFDFDULL,
1383 0xFDFDFDFDFDFDFDFDULL,
1384 0xFDFDFDFDFDFDFDFDULL,
1385 0xFDFDFDFDFDFDFDFDULL,
1386 0xFDFDFDFDFDFDFDFDULL,
1387 0xFDFDFDFDFDFDFDFDULL,
1388 0xFDFDFDFDFDFDFDFDULL
1389 }
1390 },
1391 {
1392 {
1393 0x0000000000000000ULL,
1394 0x0000000000000000ULL,
1395 0x0000000000000000ULL,
1396 0x0000000000000000ULL,
1397 0x0000000000000000ULL,
1398 0x0000000000000000ULL,
1399 0x0000000000000000ULL,
1400 0x0000000000000000ULL
1401 },
1402 {
1403 0x0000000000000000ULL,
1404 0x0000000000000000ULL,
1405 0x0000000000000000ULL,
1406 0x0000000000000000ULL,
1407 0x0000000000000000ULL,
1408 0x0000000000000000ULL,
1409 0x0000000000000000ULL,
1410 0xFD00000000000000ULL
1411 },
1412 {
1413 0x0000000000000000ULL,
1414 0x0000000000000000ULL,
1415 0x0000000000000000ULL,
1416 0x0000000000000000ULL,
1417 0x0000000000000000ULL,
1418 0x0000000000000000ULL,
1419 0xFD00000000000000ULL,
1420 0xFDFD000000000000ULL
1421 },
1422 {
1423 0x0000000000000000ULL,
1424 0x0000000000000000ULL,
1425 0x0000000000000000ULL,
1426 0x0000000000000000ULL,
1427 0x0000000000000000ULL,
1428 0xFD00000000000000ULL,
1429 0xFDFD000000000000ULL,
1430 0xFDFDFD0000000000ULL
1431 },
1432 {
1433 0x0000000000000000ULL,
1434 0x0000000000000000ULL,
1435 0x0000000000000000ULL,
1436 0x0000000000000000ULL,
1437 0xFD00000000000000ULL,
1438 0xFDFD000000000000ULL,
1439 0xFDFDFD0000000000ULL,
1440 0xFDFDFDFD00000000ULL
1441 },
1442 {
1443 0x0000000000000000ULL,
1444 0x0000000000000000ULL,
1445 0x0000000000000000ULL,
1446 0xFD00000000000000ULL,
1447 0xFDFD000000000000ULL,
1448 0xFDFDFD0000000000ULL,
1449 0xFDFDFDFD00000000ULL,
1450 0xFDFDFDFDFD000000ULL
1451 },
1452 {
1453 0x0000000000000000ULL,
1454 0x0000000000000000ULL,
1455 0xFD00000000000000ULL,
1456 0xFDFD000000000000ULL,
1457 0xFDFDFD0000000000ULL,
1458 0xFDFDFDFD00000000ULL,
1459 0xFDFDFDFDFD000000ULL,
1460 0xFDFDFDFDFDFD0000ULL
1461 },
1462 {
1463 0x0000000000000000ULL,
1464 0xFD00000000000000ULL,
1465 0xFDFD000000000000ULL,
1466 0xFDFDFD0000000000ULL,
1467 0xFDFDFDFD00000000ULL,
1468 0xFDFDFDFDFD000000ULL,
1469 0xFDFDFDFDFDFD0000ULL,
1470 0xFDFDFDFDFDFDFD00ULL
1471 },
1472 {
1473 0xFD00000000000000ULL,
1474 0xFDFD000000000000ULL,
1475 0xFDFDFD0000000000ULL,
1476 0xFDFDFDFD00000000ULL,
1477 0xFDFDFDFDFD000000ULL,
1478 0xFDFDFDFDFDFD0000ULL,
1479 0xFDFDFDFDFDFDFD00ULL,
1480 0xFDFDFDFDFDFDFDFDULL
1481 },
1482 {
1483 0xFDFD000000000000ULL,
1484 0xFDFDFD0000000000ULL,
1485 0xFDFDFDFD00000000ULL,
1486 0xFDFDFDFDFD000000ULL,
1487 0xFDFDFDFDFDFD0000ULL,
1488 0xFDFDFDFDFDFDFD00ULL,
1489 0xFDFDFDFDFDFDFDFDULL,
1490 0xFDFDFDFDFDFDFDFDULL
1491 },
1492 {
1493 0xFDFDFD0000000000ULL,
1494 0xFDFDFDFD00000000ULL,
1495 0xFDFDFDFDFD000000ULL,
1496 0xFDFDFDFDFDFD0000ULL,
1497 0xFDFDFDFDFDFDFD00ULL,
1498 0xFDFDFDFDFDFDFDFDULL,
1499 0xFDFDFDFDFDFDFDFDULL,
1500 0xFDFDFDFDFDFDFDFDULL
1501 },
1502 {
1503 0xFDFDFDFD00000000ULL,
1504 0xFDFDFDFDFD000000ULL,
1505 0xFDFDFDFDFDFD0000ULL,
1506 0xFDFDFDFDFDFDFD00ULL,
1507 0xFDFDFDFDFDFDFDFDULL,
1508 0xFDFDFDFDFDFDFDFDULL,
1509 0xFDFDFDFDFDFDFDFDULL,
1510 0xFDFDFDFDFDFDFDFDULL
1511 },
1512 {
1513 0xFDFDFDFDFD000000ULL,
1514 0xFDFDFDFDFDFD0000ULL,
1515 0xFDFDFDFDFDFDFD00ULL,
1516 0xFDFDFDFDFDFDFDFDULL,
1517 0xFDFDFDFDFDFDFDFDULL,
1518 0xFDFDFDFDFDFDFDFDULL,
1519 0xFDFDFDFDFDFDFDFDULL,
1520 0xFDFDFDFDFDFDFDFDULL
1521 },
1522 {
1523 0xFDFDFDFDFDFD0000ULL,
1524 0xFDFDFDFDFDFDFD00ULL,
1525 0xFDFDFDFDFDFDFDFDULL,
1526 0xFDFDFDFDFDFDFDFDULL,
1527 0xFDFDFDFDFDFDFDFDULL,
1528 0xFDFDFDFDFDFDFDFDULL,
1529 0xFDFDFDFDFDFDFDFDULL,
1530 0xFDFDFDFDFDFDFDFDULL
1531 },
1532 {
1533 0xFDFDFDFDFDFDFD00ULL,
1534 0xFDFDFDFDFDFDFDFDULL,
1535 0xFDFDFDFDFDFDFDFDULL,
1536 0xFDFDFDFDFDFDFDFDULL,
1537 0xFDFDFDFDFDFDFDFDULL,
1538 0xFDFDFDFDFDFDFDFDULL,
1539 0xFDFDFDFDFDFDFDFDULL,
1540 0xFDFDFDFDFDFDFDFDULL
1541 },
1542 {
1543 0xFDFDFDFDFDFDFDFDULL,
1544 0xFDFDFDFDFDFDFDFDULL,
1545 0xFDFDFDFDFDFDFDFDULL,
1546 0xFDFDFDFDFDFDFDFDULL,
1547 0xFDFDFDFDFDFDFDFDULL,
1548 0xFDFDFDFDFDFDFDFDULL,
1549 0xFDFDFDFDFDFDFDFDULL,
1550 0xFDFDFDFDFDFDFDFDULL
1551 }
1552 },
1553 {
1554 {
1555 0x0000000000000000ULL,
1556 0x0000000000000000ULL,
1557 0x0000000000000000ULL,
1558 0x0000000000000000ULL,
1559 0x0000000000000000ULL,
1560 0x0000000000000000ULL,
1561 0x0000000000000000ULL,
1562 0x0000000000000000ULL
1563 },
1564 {
1565 0x0000000000000000ULL,
1566 0x0000000000000000ULL,
1567 0x0000000000000000ULL,
1568 0x0000000000000000ULL,
1569 0x0000000000000000ULL,
1570 0x0000000000000000ULL,
1571 0x0000000000000000ULL,
1572 0x00000000000000FDULL
1573 },
1574 {
1575 0x0000000000000000ULL,
1576 0x0000000000000000ULL,
1577 0x0000000000000000ULL,
1578 0x0000000000000000ULL,
1579 0x0000000000000000ULL,
1580 0x0000000000000000ULL,
1581 0x00000000000000FDULL,
1582 0x000000000000FDFDULL
1583 },
1584 {
1585 0x0000000000000000ULL,
1586 0x0000000000000000ULL,
1587 0x0000000000000000ULL,
1588 0x0000000000000000ULL,
1589 0x0000000000000000ULL,
1590 0x00000000000000FDULL,
1591 0x000000000000FDFDULL,
1592 0x0000000000FDFDFDULL
1593 },
1594 {
1595 0x0000000000000000ULL,
1596 0x0000000000000000ULL,
1597 0x0000000000000000ULL,
1598 0x0000000000000000ULL,
1599 0x00000000000000FDULL,
1600 0x000000000000FDFDULL,
1601 0x0000000000FDFDFDULL,
1602 0x00000000FDFDFDFDULL
1603 },
1604 {
1605 0x0000000000000000ULL,
1606 0x0000000000000000ULL,
1607 0x0000000000000000ULL,
1608 0x00000000000000FDULL,
1609 0x000000000000FDFDULL,
1610 0x0000000000FDFDFDULL,
1611 0x00000000FDFDFDFDULL,
1612 0x000000FDFDFDFDFDULL
1613 },
1614 {
1615 0x0000000000000000ULL,
1616 0x0000000000000000ULL,
1617 0x00000000000000FDULL,
1618 0x000000000000FDFDULL,
1619 0x0000000000FDFDFDULL,
1620 0x00000000FDFDFDFDULL,
1621 0x000000FDFDFDFDFDULL,
1622 0x0000FDFDFDFDFDFDULL
1623 },
1624 {
1625 0x0000000000000000ULL,
1626 0x00000000000000FDULL,
1627 0x000000000000FDFDULL,
1628 0x0000000000FDFDFDULL,
1629 0x00000000FDFDFDFDULL,
1630 0x000000FDFDFDFDFDULL,
1631 0x0000FDFDFDFDFDFDULL,
1632 0x00FDFDFDFDFDFDFDULL
1633 },
1634 {
1635 0x00000000000000FDULL,
1636 0x000000000000FDFDULL,
1637 0x0000000000FDFDFDULL,
1638 0x00000000FDFDFDFDULL,
1639 0x000000FDFDFDFDFDULL,
1640 0x0000FDFDFDFDFDFDULL,
1641 0x00FDFDFDFDFDFDFDULL,
1642 0xFDFDFDFDFDFDFDFDULL
1643 },
1644 {
1645 0x000000000000FDFDULL,
1646 0x0000000000FDFDFDULL,
1647 0x00000000FDFDFDFDULL,
1648 0x000000FDFDFDFDFDULL,
1649 0x0000FDFDFDFDFDFDULL,
1650 0x00FDFDFDFDFDFDFDULL,
1651 0xFDFDFDFDFDFDFDFDULL,
1652 0xFDFDFDFDFDFDFDFDULL
1653 },
1654 {
1655 0x0000000000FDFDFDULL,
1656 0x00000000FDFDFDFDULL,
1657 0x000000FDFDFDFDFDULL,
1658 0x0000FDFDFDFDFDFDULL,
1659 0x00FDFDFDFDFDFDFDULL,
1660 0xFDFDFDFDFDFDFDFDULL,
1661 0xFDFDFDFDFDFDFDFDULL,
1662 0xFDFDFDFDFDFDFDFDULL
1663 },
1664 {
1665 0x00000000FDFDFDFDULL,
1666 0x000000FDFDFDFDFDULL,
1667 0x0000FDFDFDFDFDFDULL,
1668 0x00FDFDFDFDFDFDFDULL,
1669 0xFDFDFDFDFDFDFDFDULL,
1670 0xFDFDFDFDFDFDFDFDULL,
1671 0xFDFDFDFDFDFDFDFDULL,
1672 0xFDFDFDFDFDFDFDFDULL
1673 },
1674 {
1675 0x000000FDFDFDFDFDULL,
1676 0x0000FDFDFDFDFDFDULL,
1677 0x00FDFDFDFDFDFDFDULL,
1678 0xFDFDFDFDFDFDFDFDULL,
1679 0xFDFDFDFDFDFDFDFDULL,
1680 0xFDFDFDFDFDFDFDFDULL,
1681 0xFDFDFDFDFDFDFDFDULL,
1682 0xFDFDFDFDFDFDFDFDULL
1683 },
1684 {
1685 0x0000FDFDFDFDFDFDULL,
1686 0x00FDFDFDFDFDFDFDULL,
1687 0xFDFDFDFDFDFDFDFDULL,
1688 0xFDFDFDFDFDFDFDFDULL,
1689 0xFDFDFDFDFDFDFDFDULL,
1690 0xFDFDFDFDFDFDFDFDULL,
1691 0xFDFDFDFDFDFDFDFDULL,
1692 0xFDFDFDFDFDFDFDFDULL
1693 },
1694 {
1695 0x00FDFDFDFDFDFDFDULL,
1696 0xFDFDFDFDFDFDFDFDULL,
1697 0xFDFDFDFDFDFDFDFDULL,
1698 0xFDFDFDFDFDFDFDFDULL,
1699 0xFDFDFDFDFDFDFDFDULL,
1700 0xFDFDFDFDFDFDFDFDULL,
1701 0xFDFDFDFDFDFDFDFDULL,
1702 0xFDFDFDFDFDFDFDFDULL
1703 },
1704 {
1705 0xFDFDFDFDFDFDFDFDULL,
1706 0xFDFDFDFDFDFDFDFDULL,
1707 0xFDFDFDFDFDFDFDFDULL,
1708 0xFDFDFDFDFDFDFDFDULL,
1709 0xFDFDFDFDFDFDFDFDULL,
1710 0xFDFDFDFDFDFDFDFDULL,
1711 0xFDFDFDFDFDFDFDFDULL,
1712 0xFDFDFDFDFDFDFDFDULL
1713 }
1714 }
1715 };
1716
1717 int32_t black_opening_count=0;
1718 int32_t black_opening_x,black_opening_y;
1719 int32_t black_opening_shape;
1720
1721 791 int32_t choose_opening_shape()
1722 {
1723 // First, count how many bits are set
1724 791 int32_t numBits=0;
1725 int32_t bitCounter;
1726
1727
2/2
✓ Branch 0 taken 3955 times.
✓ Branch 1 taken 791 times.
4746 for(int32_t i=0; i<bosMAX; i++)
1728 {
1729
2/2
✓ Branch 0 taken 2948 times.
✓ Branch 1 taken 1007 times.
3955 if(COOLSCROLL&(1<<i))
1730 1007 numBits++;
1731 3955 }
1732
1733 // Shouldn't happen...
1734
1/2
✓ Branch 0 taken 791 times.
✗ Branch 1 not taken.
791 if(numBits==0)
1735 return bosCIRCLE;
1736
1737 // Pick a bit
1738 791 bitCounter=zc_rand()%numBits+1;
1739
1740
2/2
✓ Branch 0 taken 1003 times.
✓ Branch 1 taken 26 times.
1029 for(int32_t i=0; i<bosMAX; i++)
1741 {
1742 // If this bit is set, decrement the bit counter
1743
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 921 times.
1003 if(COOLSCROLL&(1<<i))
1744 921 bitCounter--;
1745
1746 // When the counter hits 0, return a value based on
1747 // which bit it stopped on.
1748 // Reminder: enum {bosCIRCLE=0, bosOVAL, bosTRIANGLE, bosSMAS, bosFADEBLACK, bosMAX};
1749
2/2
✓ Branch 0 taken 765 times.
✓ Branch 1 taken 238 times.
1003 if(bitCounter==0)
1750 765 return i;
1751 238 }
1752
1753 // Shouldn't be necessary, but the compiler might complain, at least
1754 26 return bosCIRCLE;
1755 791 }
1756
1757 216 void close_black_opening(int32_t x, int32_t y, bool wait, int32_t shape)
1758 {
1759
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 216 times.
216 black_opening_shape= (shape>-1 ? shape : choose_opening_shape());
1760
1761 216 int32_t w=256, h=224;
1762 216 int32_t blockrows=28, blockcolumns=32;
1763 216 int32_t xoffset=(x-(w/2))/8, yoffset=(y-(h/2))/8;
1764
1765
2/2
✓ Branch 0 taken 6048 times.
✓ Branch 1 taken 216 times.
6264 for(int32_t blockrow=0; blockrow<blockrows; ++blockrow) //30
1766 {
1767
2/2
✓ Branch 0 taken 193536 times.
✓ Branch 1 taken 6048 times.
199584 for(int32_t blockcolumn=0; blockcolumn<blockcolumns; ++blockcolumn) //40
1768 {
1769
2/2
✓ Branch 0 taken 103944 times.
✓ Branch 1 taken 89592 times.
193536 screen_triangles[blockrow][blockcolumn]=zc_max(abs(int32_t(double(blockcolumns-1)/2-blockcolumn+xoffset)),abs(int32_t(double(blockrows-1)/2-blockrow+yoffset)))|0x0100|((blockrow-yoffset<blockrows/2)?0:0x8000)|((blockcolumn-xoffset<blockcolumns/2)?0x4000:0);
1770 193536 }
1771 6048 }
1772
1773 216 black_opening_count = 66;
1774 216 black_opening_x = x;
1775 216 black_opening_y = y;
1776 216 lensclk = 0;
1777 //black_opening_shape=(black_opening_shape+1)%bosMAX;
1778
1779
1780
1/2
✓ Branch 0 taken 216 times.
✗ Branch 1 not taken.
216 if(black_opening_shape == bosFADEBLACK)
1781 {
1782 refreshTints();
1783 memcpy(tempblackpal, RAMpal, sizeof(RAMpal)); //Store palette in temp palette for fade effect
1784 }
1785
1/2
✓ Branch 0 taken 216 times.
✗ Branch 1 not taken.
216 if(wait)
1786 {
1787 FFCore.warpScriptCheck();
1788 for(int32_t i=0; i<66; i++)
1789 {
1790 draw_screen(tmpscr);
1791 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
1792 advanceframe(true);
1793
1794 if(Quit)
1795 {
1796 break;
1797 }
1798 }
1799 }
1800 216 }
1801
1802 575 void open_black_opening(int32_t x, int32_t y, bool wait, int32_t shape)
1803 {
1804
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 575 times.
575 black_opening_shape= (shape>-1 ? shape : choose_opening_shape());
1805
1806 575 int32_t w=256, h=224;
1807 575 int32_t blockrows=28, blockcolumns=32;
1808 575 int32_t xoffset=(x-(w/2))/8, yoffset=(y-(h/2))/8;
1809
1810
2/2
✓ Branch 0 taken 16100 times.
✓ Branch 1 taken 575 times.
16675 for(int32_t blockrow=0; blockrow<blockrows; ++blockrow) //30
1811 {
1812
2/2
✓ Branch 0 taken 515200 times.
✓ Branch 1 taken 16100 times.
531300 for(int32_t blockcolumn=0; blockcolumn<blockcolumns; ++blockcolumn) //40
1813 {
1814
2/2
✓ Branch 0 taken 241603 times.
✓ Branch 1 taken 273597 times.
515200 screen_triangles[blockrow][blockcolumn]=zc_max(abs(int32_t(double(blockcolumns-1)/2-blockcolumn+xoffset)),abs(int32_t(double(blockrows-1)/2-blockrow+yoffset)))|0x0100|((blockrow-yoffset<blockrows/2)?0:0x8000)|((blockcolumn-xoffset<blockcolumns/2)?0x4000:0);
1815 515200 }
1816 16100 }
1817
1818 575 black_opening_count = -66;
1819 575 black_opening_x = x;
1820 575 black_opening_y = y;
1821 575 lensclk = 0;
1822
1/2
✓ Branch 0 taken 575 times.
✗ Branch 1 not taken.
575 if(black_opening_shape == bosFADEBLACK)
1823 {
1824 refreshTints();
1825 memcpy(tempblackpal, RAMpal, sizeof(RAMpal)); //Store palette in temp palette for fade effect
1826 }
1827
2/2
✓ Branch 0 taken 110 times.
✓ Branch 1 taken 465 times.
575 if(wait)
1828 {
1829 465 FFCore.warpScriptCheck();
1830
2/2
✓ Branch 0 taken 465 times.
✓ Branch 1 taken 30690 times.
31155 for(int32_t i=0; i<66; i++)
1831 {
1832 30690 draw_screen(tmpscr);
1833 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
1834 30690 advanceframe(true);
1835
1836
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30690 times.
30690 if(Quit)
1837 {
1838 break;
1839 }
1840 30690 }
1841 465 }
1842 575 }
1843
1844 52206 void black_opening(BITMAP *dest,int32_t x,int32_t y,int32_t a,int32_t max_a)
1845 {
1846 52206 clear_to_color(tmp_scr,BLACK);
1847 52206 int32_t w=256, h=224;
1848
1849
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 858 times.
✓ Branch 2 taken 660 times.
✓ Branch 3 taken 1650 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 49038 times.
52206 switch(black_opening_shape)
1850 {
1851 case bosOVAL:
1852 {
1853 858 double new_w=(w/2)+abs(w/2-x);
1854 858 double new_h=(h/2)+abs(h/2-y);
1855 858 double b=sqrt(((new_w*new_w)/4)+(new_h*new_h));
1856 858 ellipsefill(tmp_scr,x,y,int32_t(2*a*b/max_a)/8*8,int32_t(a*b/max_a)/8*8,0);
1857 858 break;
1858 }
1859
1860 case bosTRIANGLE:
1861 {
1862 660 double new_w=(w/2)+abs(w/2-x);
1863 660 double new_h=(h/2)+abs(h/2-y);
1864 660 double r=a*(new_w*sqrt((double)3)+new_h)/max_a;
1865 660 double P2= (PI/2);
1866 660 double P23=(2*PI/3);
1867 660 double P43=(4*PI/3);
1868 660 double Pa= (-4*PI*a/(3*max_a));
1869 660 double angle=P2+Pa;
1870 660 double a0=angle;
1871 660 double a2=angle+P23;
1872 660 double a4=angle+P43;
1873 1320 triangle(tmp_scr, x+int32_t(zc::math::Cos(a0)*r), y-int32_t(zc::math::Sin(a0)*r),
1874 660 x+int32_t(zc::math::Cos(a2)*r), y-int32_t(zc::math::Sin(a2)*r),
1875 660 x+int32_t(zc::math::Cos(a4)*r), y-int32_t(zc::math::Sin(a4)*r),
1876 0);
1877 660 break;
1878 }
1879
1880 case bosSMAS:
1881 {
1882
2/2
✓ Branch 0 taken 660 times.
✓ Branch 1 taken 990 times.
1650 int32_t distance=zc_max(abs(w/2-x),abs(h/2-y))/8;
1883
1884
2/2
✓ Branch 0 taken 46200 times.
✓ Branch 1 taken 1650 times.
47850 for(int32_t blockrow=0; blockrow<28; ++blockrow) //30
1885 {
1886
2/2
✓ Branch 0 taken 369600 times.
✓ Branch 1 taken 46200 times.
415800 for(int32_t linerow=0; linerow<8; ++linerow)
1887 {
1888 369600 qword *triangleline=(qword*)(tmp_scr->line[(blockrow*8+linerow)]);
1889
1890
2/2
✓ Branch 0 taken 11827200 times.
✓ Branch 1 taken 369600 times.
12196800 for(int32_t blockcolumn=0; blockcolumn<32; ++blockcolumn) //40
1891 {
1892 35481600 *triangleline=triangles[(screen_triangles[blockrow][blockcolumn]&0xC000)>>14]
1893
6/6
✓ Branch 0 taken 8249728 times.
✓ Branch 1 taken 3577472 times.
✓ Branch 2 taken 7829672 times.
✓ Branch 3 taken 3997528 times.
✓ Branch 4 taken 4252200 times.
✓ Branch 5 taken 3577472 times.
11827200 [zc_min(zc_max((((31+distance)*(max_a-a)/max_a)+((screen_triangles[blockrow][blockcolumn]&0x0FFF)-0x0100)-(15+distance)),0),15)]
1894 11827200 [linerow];
1895 11827200 ++triangleline;
1896
1897
2/2
✓ Branch 0 taken 10348800 times.
✓ Branch 1 taken 1478400 times.
11827200 if(linerow==0)
1898 {
1899 1478400 }
1900 11827200 }
1901 369600 }
1902 46200 }
1903
1904 1650 break;
1905 }
1906
1907 case bosFADEBLACK:
1908 {
1909 if(black_opening_count<0)
1910 {
1911 black_fade(zc_min(-black_opening_count,63));
1912 }
1913 else if(black_opening_count>0)
1914 {
1915 black_fade(63-zc_max(black_opening_count-3,0));
1916 }
1917 else black_fade(0);
1918 return; //no blitting from tmp_scr!
1919 }
1920
1921 49038 case bosCIRCLE:
1922 default:
1923 {
1924 49038 double new_w=(w/2)+abs(w/2-x);
1925 49038 double new_h=(h/2)+abs(h/2-y);
1926 49038 int32_t r=int32_t(sqrt((new_w*new_w)+(new_h*new_h))*a/max_a);
1927 //circlefill(tmp_scr,x,y,a<<3,0);
1928 49038 circlefill(tmp_scr,x,y,r,0);
1929 49038 break;
1930 }
1931 }
1932
1933 52206 masked_blit(tmp_scr,dest,0,0,0,0,320,240);
1934 52206 }
1935
1936
1937 void black_fade(int32_t fadeamnt)
1938 {
1939 for(int32_t i=0; i < 0xEF; i++)
1940 {
1941 RAMpal[i].r = vbound(tempblackpal[i].r-fadeamnt,0,63);
1942 RAMpal[i].g = vbound(tempblackpal[i].g-fadeamnt,0,63);
1943 RAMpal[i].b = vbound(tempblackpal[i].b-fadeamnt,0,63);
1944 }
1945
1946 refreshpal = true;
1947 }
1948
1949 //----------------------------------------------------------------
1950
1951 15952490 bool item_disabled(int32_t item) //is this item disabled?
1952 {
1953
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15952490 times.
15952490 return (item>=0 && game->items_off[item] != 0);
1954 }
1955
1956 5426600 bool can_use_item(int32_t item_type, int32_t item) //can Hero use this item?
1957 {
1958
2/2
✓ Branch 0 taken 57842 times.
✓ Branch 1 taken 5368758 times.
5426600 if(current_item(item_type, true) >=item)
1959 {
1960 57842 return true;
1961 }
1962
1963 5368758 return false;
1964 5426600 }
1965
1966 22449319 bool has_item(int32_t item_type, int32_t it) //does Hero possess this item?
1967 {
1968
5/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 4086346 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2439977 times.
✓ Branch 6 taken 12012783 times.
✓ Branch 7 taken 3882589 times.
✓ Branch 8 taken 27624 times.
22449319 switch(item_type)
1969 {
1970 case itype_bomb:
1971 case itype_sbomb:
1972 {
1973 int32_t itemid = getItemID(itemsbuf, item_type, it);
1974
1975 if(itemid == -1)
1976 return false;
1977
1978 return (game->get_item(itemid));
1979 }
1980
1981 case itype_clock:
1982 {
1983 4086346 int32_t itemid = getItemID(itemsbuf, item_type, it);
1984
1985
2/4
✓ Branch 0 taken 4086346 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4086346 times.
✗ Branch 3 not taken.
4086346 if(itemid != -1 && (itemsbuf[itemid].flags & ITEM_FLAG1)) //Active clock
1986 return (game->get_item(itemid));
1987 4086346 return Hero.getClock()?1:0;
1988 }
1989
1990 case itype_key:
1991 return (game->get_keys()>0);
1992
1993 case itype_magiccontainer:
1994 return (game->get_maxmagic()>=game->get_mp_per_block());
1995
1996 case itype_triforcepiece: //it: -2=any, -1=current level, other=that level
1997 {
1998
1/3
✓ Branch 0 taken 2439977 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
2439977 switch(it)
1999 {
2000 case -2:
2001 {
2002 for(int32_t i=0; i<MAXLEVELS; i++)
2003 {
2004 if(game->lvlitems[i]&liTRIFORCE)
2005 {
2006 return true;
2007 }
2008 }
2009
2010 return false;
2011 }
2012
2013 case -1:
2014 return (game->lvlitems[dlevel]&liTRIFORCE);
2015
2016 default:
2017
2/4
✓ Branch 0 taken 2439977 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2439977 times.
2439977 if(it>=0&&it<MAXLEVELS)
2018 {
2019 2439977 return (game->lvlitems[it]&liTRIFORCE);
2020 }
2021
2022 break;
2023 }
2024
2025 return 0;
2026 }
2027
2028 case itype_map: //it: -2=any, -1=current level, other=that level
2029 {
2030
1/3
✓ Branch 0 taken 12012783 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
12012783 switch(it)
2031 {
2032 case -2:
2033 {
2034 for(int32_t i=0; i<MAXLEVELS; i++)
2035 {
2036 if(game->lvlitems[i]&liMAP)
2037 {
2038 return true;
2039 }
2040 }
2041
2042 return false;
2043 }
2044
2045 case -1:
2046 return (game->lvlitems[dlevel]&liMAP)!=0;
2047
2048 default:
2049
2/4
✓ Branch 0 taken 12012783 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 12012783 times.
12012783 if(it>=0&&it<MAXLEVELS)
2050 {
2051 12012783 return (game->lvlitems[it]&liMAP)!=0;
2052 }
2053
2054 break;
2055 }
2056
2057 return 0;
2058 }
2059
2060 case itype_compass: //it: -2=any, -1=current level, other=that level
2061 {
2062
1/3
✓ Branch 0 taken 3882589 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
3882589 switch(it)
2063 {
2064 case -2:
2065 {
2066 for(int32_t i=0; i<MAXLEVELS; i++)
2067 {
2068 if(game->lvlitems[i]&liCOMPASS)
2069 {
2070 return true;
2071 }
2072 }
2073
2074 return false;
2075 }
2076
2077 case -1:
2078 return (game->lvlitems[dlevel]&liCOMPASS)!=0;
2079
2080 default:
2081
2/4
✓ Branch 0 taken 3882589 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3882589 times.
✗ Branch 3 not taken.
3882589 if(it>=0&&it<MAXLEVELS)
2082 {
2083 3882589 return (game->lvlitems[it]&liCOMPASS)!=0;
2084 }
2085
2086 break;
2087 }
2088 return 0;
2089 }
2090
2091 case itype_bosskey: //it: -2=any, -1=current level, other=that level
2092 {
2093
1/3
✓ Branch 0 taken 27624 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
27624 switch(it)
2094 {
2095 case -2:
2096 {
2097 for(int32_t i=0; i<MAXLEVELS; i++)
2098 {
2099 if(game->lvlitems[i]&liBOSSKEY)
2100 {
2101 return true;
2102 }
2103 }
2104
2105 return false;
2106 }
2107
2108 case -1:
2109 return (game->lvlitems[dlevel]&liBOSSKEY)?1:0;
2110
2111 default:
2112
2/4
✓ Branch 0 taken 27624 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 27624 times.
27624 if(it>=0&&it<MAXLEVELS)
2113 {
2114 27624 return (game->lvlitems[it]&liBOSSKEY)?1:0;
2115 }
2116 break;
2117 }
2118 return 0;
2119 }
2120
2121 default:
2122 //it=(1<<(it-1));
2123 /*if (item_type>=itype_max)
2124 {
2125 system_pal();
2126 jwin_alert("Error","has_item exception",NULL,NULL,"O&K",NULL,'k',0,lfont);
2127 game_pal();
2128
2129 return false;
2130 }*/
2131 int32_t itemid = getItemID(itemsbuf, item_type, it);
2132
2133 if(itemid == -1)
2134 return false;
2135
2136 return game->get_item(itemid);
2137 }
2138 22449319 }
2139
2140
2141 69865212 int32_t current_item(int32_t item_type, bool checkenabled) //item currently being used
2142 {
2143
9/9
✓ Branch 0 taken 4086346 times.
✓ Branch 1 taken 37174444 times.
✓ Branch 2 taken 4086346 times.
✓ Branch 3 taken 4086346 times.
✓ Branch 4 taken 4086346 times.
✓ Branch 5 taken 4086346 times.
✓ Branch 6 taken 4086346 times.
✓ Branch 7 taken 4086346 times.
✓ Branch 8 taken 4086346 times.
69865212 switch(item_type)
2144 {
2145 case itype_clock:
2146 {
2147 4086346 int32_t maxid = getHighestLevelOfFamily(game, itemsbuf, item_type, checkenabled);
2148
2149
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4086346 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4086346 if(maxid != -1 && (itemsbuf[maxid].flags & ITEM_FLAG1)) //Active clock
2150 return itemsbuf[maxid].fam_type;
2151
2152 4086346 return has_item(itype_clock,1) ? 1 : 0;
2153 }
2154
2155 case itype_key:
2156 4086346 return game->get_keys();
2157
2158 case itype_lkey:
2159 4086346 return game->lvlkeys[get_dlevel()];
2160
2161 case itype_magiccontainer:
2162 4086346 return game->get_maxmagic()/game->get_mp_per_block();
2163
2164 case itype_triforcepiece:
2165 {
2166 4086346 int32_t count=0;
2167
2168
2/2
✓ Branch 0 taken 2092209152 times.
✓ Branch 1 taken 4086346 times.
2096295498 for(int32_t i=0; i<MAXLEVELS; i++)
2169 {
2170 2092209152 count+=(game->lvlitems[i]&liTRIFORCE)?1:0;
2171 2092209152 }
2172
2173 4086346 return count;
2174 }
2175
2176 case itype_map:
2177 {
2178 4086346 int32_t count=0;
2179
2180
2/2
✓ Branch 0 taken 2092209152 times.
✓ Branch 1 taken 4086346 times.
2096295498 for(int32_t i=0; i<MAXLEVELS; i++)
2181 {
2182 2092209152 count+=(game->lvlitems[i]&liMAP)?1:0;
2183 2092209152 }
2184
2185 4086346 return count;
2186 }
2187
2188 case itype_compass:
2189 {
2190 4086346 int32_t count=0;
2191
2192
2/2
✓ Branch 0 taken 2092209152 times.
✓ Branch 1 taken 4086346 times.
2096295498 for(int32_t i=0; i<MAXLEVELS; i++)
2193 {
2194 2092209152 count+=(game->lvlitems[i]&liCOMPASS)?1:0;
2195 2092209152 }
2196
2197 4086346 return count;
2198 }
2199
2200 case itype_bosskey:
2201 {
2202 4086346 int32_t count=0;
2203
2204
2/2
✓ Branch 0 taken 2092209152 times.
✓ Branch 1 taken 4086346 times.
2096295498 for(int32_t i=0; i<MAXLEVELS; i++)
2205 {
2206 2092209152 count+=(game->lvlitems[i]&liBOSSKEY)?1:0;
2207 2092209152 }
2208
2209 4086346 return count;
2210 }
2211
2212 default:
2213 37174444 int32_t maxid = getHighestLevelOfFamily(game, itemsbuf, item_type, checkenabled);
2214
2215
2/2
✓ Branch 0 taken 6971052 times.
✓ Branch 1 taken 30203392 times.
37174444 if(maxid == -1)
2216 30203392 return 0;
2217
2218 6971052 return itemsbuf[maxid].fam_type;
2219 }
2220 69865212 }
2221
2222 64438612 int32_t current_item(int32_t item_type) //item currently being used
2223 {
2224 64438612 return current_item(item_type, true);
2225 }
2226
2227 29 std::map<int32_t, int32_t> itemcache;
2228
2229 // Not actually used by anything at the moment...
2230 void removeFromItemCache(int32_t itemid)
2231 {
2232 itemcache.erase(itemid);
2233 }
2234
2235 19096 void flushItemCache()
2236 {
2237 19096 itemcache.clear();
2238
2239 //also fix the active subscreen if items were deleted -DD
2240
1/2
✓ Branch 0 taken 19096 times.
✗ Branch 1 not taken.
19096 if(game != NULL)
2241 {
2242 19096 verifyBothWeapons();
2243 19096 load_Sitems(&QMisc);
2244 19096 }
2245 19096 }
2246
2247 // This is used often, so it should be as direct as possible.
2248 2281813085 int32_t _c_item_id_internal(int32_t itemtype, bool checkmagic, bool jinx_check)
2249 {
2250
2/2
✓ Branch 0 taken 2233008728 times.
✓ Branch 1 taken 48804357 times.
2281813085 if(jinx_check)
2251 {
2252
4/4
✓ Branch 0 taken 31164925 times.
✓ Branch 1 taken 17639432 times.
✓ Branch 2 taken 27758483 times.
✓ Branch 3 taken 3406442 times.
48804357 if(!(HeroSwordClk() || HeroItemClk()))
2253 27758483 jinx_check = false; //not jinxed
2254 48804357 }
2255
4/4
✓ Branch 0 taken 2262409545 times.
✓ Branch 1 taken 19403540 times.
✓ Branch 2 taken 20897290 times.
✓ Branch 3 taken 2241512255 times.
2281813085 if(itemtype!=itype_ring && !jinx_check) // Rings must always be checked, as must jinx checks...
2256 {
2257 2241512255 std::map<int32_t,int32_t>::iterator res = itemcache.find(itemtype);
2258
2259
2/2
✓ Branch 0 taken 2231763743 times.
✓ Branch 1 taken 9748512 times.
2241512255 if(res != itemcache.end())
2260 2231763743 return res->second;
2261 9748512 }
2262
2263 50049342 int32_t result = -1;
2264 50049342 int32_t highestlevel = -1;
2265
2266
2/2
✓ Branch 0 taken 12812631552 times.
✓ Branch 1 taken 50049342 times.
12862680894 for(int32_t i=0; i<MAXITEMS; i++)
2267 {
2268
5/6
✓ Branch 0 taken 1030627526 times.
✓ Branch 1 taken 11782004026 times.
✓ Branch 2 taken 15409861 times.
✓ Branch 3 taken 1015217665 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 15409861 times.
12812631552 if(game->get_item(i) && itemsbuf[i].family==itemtype && !item_disabled(i))
2269 {
2270
4/4
✓ Branch 0 taken 4655389 times.
✓ Branch 1 taken 10754472 times.
✓ Branch 2 taken 1195206 times.
✓ Branch 3 taken 14214655 times.
15409861 if((checkmagic || itemtype == itype_ring) && itemtype != itype_magicring)
2271 {
2272 //printf("Checkmagic for %d: %d (%d %d)\n",i,checkmagiccost(i),itemsbuf[i].magic*game->get_magicdrainrate(),game->get_magic());
2273
2/2
✓ Branch 0 taken 14214535 times.
✓ Branch 1 taken 120 times.
14214655 if(!checkmagiccost(i))
2274 {
2275
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 108 times.
120 if ( !get_bit(quest_rules,qr_NEVERDISABLEAMMOONSUBSCREEN) ) continue; //don't make items with a magic cost vanish!! -Z
2276 12 }
2277 14214547 }
2278
6/6
✓ Branch 0 taken 13234243 times.
✓ Branch 1 taken 2175510 times.
✓ Branch 2 taken 229100 times.
✓ Branch 3 taken 1946410 times.
✓ Branch 4 taken 1458492 times.
✓ Branch 5 taken 717018 times.
15409753 if(jinx_check && (usesSwordJinx(i) ? HeroSwordClk() : HeroItemClk()))
2279 {
2280
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 717018 times.
717018 if(!(itemsbuf[i].flags & ITEM_JINX_IMMUNE))
2281 717018 continue;
2282 }
2283
2284
2/2
✓ Branch 0 taken 223586 times.
✓ Branch 1 taken 14469149 times.
14692735 if(itemsbuf[i].fam_type >= highestlevel)
2285 {
2286 14469149 highestlevel = itemsbuf[i].fam_type;
2287 14469149 result=i;
2288 14469149 }
2289 14692735 }
2290 12811914426 }
2291
2292
2/2
✓ Branch 0 taken 21045874 times.
✓ Branch 1 taken 29003468 times.
50049342 if(!jinx_check) //Can't cache jinx_check results
2293 29003468 itemcache[itemtype] = result;
2294 50049342 return result;
2295 2281813085 }
2296
2297 // 'jinx_check' indicates that the highest level item *immune to jinxes* should be returned.
2298 2261047794 int32_t current_item_id(int32_t itemtype, bool checkmagic, bool jinx_check)
2299 {
2300 2261047794 auto ret = _c_item_id_internal(itemtype,checkmagic,jinx_check);
2301
2/2
✓ Branch 0 taken 28039066 times.
✓ Branch 1 taken 2233008728 times.
2261047794 if(!jinx_check) //If not already a jinx-immune-only check...
2302 {
2303 //And the player IS jinxed...
2304
4/4
✓ Branch 0 taken 2215600801 times.
✓ Branch 1 taken 17407927 times.
✓ Branch 2 taken 3357364 times.
✓ Branch 3 taken 2212243437 times.
2233008728 if(HeroSwordClk() || HeroItemClk())
2305 {
2306 //Then do a jinx-immune-only check here
2307 20765291 auto ret2 = _c_item_id_internal(itemtype,checkmagic,true);
2308 //And *IF IT FINDS A VALID ITEM*, return that one instead! -Em
2309 //Should NOT need a compat rule, as this should always return -1 in old quests.
2310
2/2
✓ Branch 0 taken 974915 times.
✓ Branch 1 taken 19790376 times.
20765291 if(ret2 > -1) return ret2;
2311 19790376 }
2312 2232033813 }
2313 2260072879 return ret;
2314 2261047794 }
2315 14776608 int32_t current_item_power(int32_t itemtype)
2316 {
2317 14776608 int32_t result = current_item_id(itemtype,true);
2318
2/2
✓ Branch 0 taken 11445380 times.
✓ Branch 1 taken 3331228 times.
14776608 return (result<0) ? 0 : itemsbuf[result].power;
2319 }
2320
2321 7 int32_t heart_container_id()
2322 {
2323
1/2
✓ Branch 0 taken 203 times.
✗ Branch 1 not taken.
203 for(int32_t i=0; i<MAXITEMS; i++)
2324 {
2325
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 196 times.
203 if(itemsbuf[i].family == itype_heartcontainer)
2326 {
2327 7 return i;
2328 }
2329 196 }
2330 return -1;
2331 7 }
2332
2333 4086346 int32_t item_tile_mod()
2334 {
2335 4086346 int32_t tile=0;
2336
2337
2/2
✓ Branch 0 taken 975760 times.
✓ Branch 1 taken 3110586 times.
4086346 if(game->get_bombs())
2338 {
2339 3110586 int32_t itemid = current_item_id(itype_bomb,false);
2340
3/4
✓ Branch 0 taken 3029527 times.
✓ Branch 1 taken 81059 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3029527 times.
3110586 if(itemid > -1 && checkbunny(itemid))
2341 3029527 tile+=itemsbuf[itemid].ltm;
2342 3110586 }
2343
2344
2/2
✓ Branch 0 taken 3032663 times.
✓ Branch 1 taken 1053683 times.
4086346 if(game->get_sbombs())
2345 {
2346 1053683 int32_t itemid = current_item_id(itype_sbomb,false);
2347
3/4
✓ Branch 0 taken 1052255 times.
✓ Branch 1 taken 1428 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1052255 times.
1053683 if(itemid > -1 && checkbunny(itemid))
2348 1052255 tile+=itemsbuf[itemid].ltm;
2349 1053683 }
2350
2351
2/2
✓ Branch 0 taken 3998396 times.
✓ Branch 1 taken 87950 times.
4086346 if(current_item(itype_clock))
2352 {
2353 87950 int32_t itemid =
2354
1/2
✓ Branch 0 taken 87950 times.
✗ Branch 1 not taken.
87950 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2355 ? iClock
2356 : getHighestLevelEvenUnowned(itemsbuf, itype_clock);
2357
2/4
✓ Branch 0 taken 87950 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 87950 times.
87950 if(itemid > -1 && checkbunny(itemid))
2358 87950 tile+=itemsbuf[itemid].ltm;
2359 87950 }
2360
2361
2/2
✓ Branch 0 taken 3438526 times.
✓ Branch 1 taken 647820 times.
4086346 if(current_item(itype_key))
2362 {
2363 647820 int32_t itemid =
2364
1/2
✓ Branch 0 taken 647820 times.
✗ Branch 1 not taken.
647820 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2365 ? iKey
2366 : getHighestLevelEvenUnowned(itemsbuf, itype_key);
2367
2/4
✓ Branch 0 taken 647820 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 647820 times.
647820 if(itemid > -1 && checkbunny(itemid))
2368 647820 tile+=itemsbuf[itemid].ltm;
2369 647820 }
2370
2371
2/2
✓ Branch 0 taken 3927093 times.
✓ Branch 1 taken 159253 times.
4086346 if(current_item(itype_lkey))
2372 {
2373 159253 int32_t itemid =
2374
2/2
✓ Branch 0 taken 158343 times.
✓ Branch 1 taken 910 times.
159253 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2375 ? iLevelKey
2376 910 : getHighestLevelEvenUnowned(itemsbuf, itype_lkey);
2377
2/4
✓ Branch 0 taken 159253 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 159253 times.
159253 if(itemid > -1 && checkbunny(itemid))
2378 159253 tile+=itemsbuf[itemid].ltm;
2379 159253 }
2380
2381
2/2
✓ Branch 0 taken 886117 times.
✓ Branch 1 taken 3200229 times.
4086346 if(current_item(itype_map))
2382 {
2383 3200229 int32_t itemid =
2384
2/2
✓ Branch 0 taken 3199443 times.
✓ Branch 1 taken 786 times.
3200229 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2385 ? iMap
2386 786 : getHighestLevelEvenUnowned(itemsbuf, itype_map);
2387
2/4
✓ Branch 0 taken 3200229 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3200229 times.
3200229 if(itemid > -1 && checkbunny(itemid))
2388 3200229 tile+=itemsbuf[itemid].ltm;
2389 3200229 }
2390
2391
2/2
✓ Branch 0 taken 807819 times.
✓ Branch 1 taken 3278527 times.
4086346 if(current_item(itype_compass))
2392 {
2393 3278527 int32_t itemid =
2394
2/2
✓ Branch 0 taken 3197468 times.
✓ Branch 1 taken 81059 times.
3278527 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2395 ? iCompass
2396 81059 : getHighestLevelEvenUnowned(itemsbuf, itype_compass);
2397
2/4
✓ Branch 0 taken 3278527 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3278527 times.
3278527 if(itemid > -1 && checkbunny(itemid))
2398 3278527 tile+=itemsbuf[itemid].ltm;
2399 3278527 }
2400
2401
2/2
✓ Branch 0 taken 2275984 times.
✓ Branch 1 taken 1810362 times.
4086346 if(current_item(itype_bosskey))
2402 {
2403 1810362 int32_t itemid =
2404
1/2
✓ Branch 0 taken 1810362 times.
✗ Branch 1 not taken.
1810362 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2405 ? iBossKey
2406 : getHighestLevelEvenUnowned(itemsbuf, itype_bosskey);
2407
2/4
✓ Branch 0 taken 1810362 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1810362 times.
1810362 if(itemid > -1 && checkbunny(itemid))
2408 1810362 tile+=itemsbuf[itemid].ltm;
2409 1810362 }
2410
2411
2/2
✓ Branch 0 taken 2141126 times.
✓ Branch 1 taken 1945220 times.
4086346 if(current_item(itype_magiccontainer))
2412 {
2413 1945220 int32_t itemid =
2414
2/2
✓ Branch 0 taken 1852005 times.
✓ Branch 1 taken 93215 times.
1945220 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2415 ? iMagicC
2416 93215 : getHighestLevelEvenUnowned(itemsbuf, itype_magiccontainer);
2417
3/4
✓ Branch 0 taken 1945220 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1870 times.
✓ Branch 3 taken 1943350 times.
1945220 if(itemid > -1 && checkbunny(itemid))
2418 1943350 tile+=itemsbuf[itemid].ltm;
2419 1945220 }
2420
2421
2/2
✓ Branch 0 taken 1118041 times.
✓ Branch 1 taken 2968305 times.
4086346 if(current_item(itype_triforcepiece))
2422 {
2423 2968305 int32_t itemid =
2424
1/2
✓ Branch 0 taken 2968305 times.
✗ Branch 1 not taken.
2968305 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2425 ? iTriforce
2426 : getHighestLevelEvenUnowned(itemsbuf, itype_triforcepiece);
2427
2/4
✓ Branch 0 taken 2968305 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2968305 times.
2968305 if(itemid > -1 && checkbunny(itemid))
2428 2968305 tile+=itemsbuf[itemid].ltm;
2429 2968305 }
2430
2431
2/2
✓ Branch 0 taken 4086346 times.
✓ Branch 1 taken 2092209152 times.
2096295498 for(int32_t i=0; i<itype_max; i++)
2432 {
2433
2/2
✓ Branch 0 taken 2035907072 times.
✓ Branch 1 taken 56302080 times.
2092209152 if(!get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS))
2434 {
2435
2/2
✓ Branch 0 taken 1099650 times.
✓ Branch 1 taken 55202430 times.
56302080 switch(i)
2436 {
2437 case itype_bomb:
2438 case itype_sbomb:
2439 case itype_clock:
2440 case itype_key:
2441 case itype_lkey:
2442 case itype_map:
2443 case itype_compass:
2444 case itype_bosskey:
2445 case itype_magiccontainer:
2446 case itype_triforcepiece:
2447 1099650 continue; //already handled
2448 }
2449 55202430 }
2450 2091109502 int32_t itemid = current_item_id(i,false);
2451
2/2
✓ Branch 0 taken 2087023156 times.
✓ Branch 1 taken 4086346 times.
2091109502 if(i == itype_shield)
2452 4086346 itemid = getCurrentShield(false);
2453
2454
4/4
✓ Branch 0 taken 59139201 times.
✓ Branch 1 taken 2031970301 times.
✓ Branch 2 taken 100981 times.
✓ Branch 3 taken 59038220 times.
2091109502 if(itemid < 0 || !checkbunny(itemid))
2455 2032071282 continue;
2456
2457 59038220 itemdata const& itm = itemsbuf[itemid];
2458
2459
2/2
✓ Branch 0 taken 55529396 times.
✓ Branch 1 taken 3508824 times.
59038220 switch(itm.family)
2460 {
2461 case itype_shield:
2462
1/2
✓ Branch 0 taken 3508824 times.
✗ Branch 1 not taken.
3508824 if(itm.flags & ITEM_FLAG9) //active shield
2463 {
2464 if(!usingActiveShield(itemid))
2465 {
2466 tile+=itm.misc6; //'Inactive PTM'
2467 continue;
2468 }
2469 }
2470 3508824 break;
2471 }
2472
2473 59038220 tile+=itm.ltm;
2474 59038220 }
2475
2476 4086346 return tile;
2477 }
2478
2479 4086346 int32_t bunny_tile_mod()
2480 {
2481
2/2
✓ Branch 0 taken 1870 times.
✓ Branch 1 taken 4084476 times.
4086346 if(Hero.BunnyClock())
2482 {
2483 1870 return game->get_bunny_ltm();
2484 }
2485 4084476 return 0;
2486 4086346 }
2487
2488 // Hints are drawn on a separate layer to combo reveals.
2489 16332 void draw_lens_under(BITMAP *dest, bool layer)
2490 {
2491 //Lens flag 1: Replacement for qr_LENSHINTS; if set, lens will show hints. Does nothing if flag 2 is set.
2492 //Lens flag 2: Disable "hints", prevent rendering of Secret Combos
2493 //Lens flag 3: Don't show armos/chest/dive items
2494 //Lens flag 4: Show Raft Paths
2495 //Lens flag 5: Show Invisible Enemies
2496
4/4
✓ Branch 0 taken 456 times.
✓ Branch 1 taken 15876 times.
✓ Branch 2 taken 7938 times.
✓ Branch 3 taken 7938 times.
16332 bool hints = (itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2) ? false : (layer && (itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG1));
2497
2498 16332 int32_t strike_hint_table[11]=
2499 {
2500 mfARROW, mfBOMB, mfBRANG, mfWANDMAGIC,
2501 mfSWORD, mfREFMAGIC, mfHOOKSHOT,
2502 mfREFFIREBALL, mfHAMMER, mfSWORDBEAM, mfWAND
2503 };
2504
2505 // int32_t page = tmpscr->cpage;
2506 {
2507 16332 int32_t blink_rate=flash_reduction_enabled()?6:1;
2508 // int32_t temptimer=0;
2509 16332 int32_t tempitem, tempweapon=0;
2510 16332 strike_hint=strike_hint_table[strike_hint_counter];
2511
2512
2/2
✓ Branch 0 taken 15840 times.
✓ Branch 1 taken 492 times.
16332 if(strike_hint_timer>32)
2513 {
2514 492 strike_hint_timer=0;
2515 492 strike_hint_counter=((strike_hint_counter+1)%11);
2516 492 }
2517
2518 16332 ++strike_hint_timer;
2519
2520
2/2
✓ Branch 0 taken 2874432 times.
✓ Branch 1 taken 16332 times.
2890764 for(int32_t i=0; i<176; i++)
2521 {
2522 2874432 int32_t x = (i & 15) << 4;
2523 2874432 int32_t y = (i & 0xF0) + playing_field_offset;
2524 2874432 int32_t tempitemx=-16, tempitemy=-16;
2525 2874432 int32_t tempweaponx=-16, tempweapony=-16;
2526
2527
2/2
✓ Branch 0 taken 5748864 times.
✓ Branch 1 taken 2874432 times.
8623296 for(int32_t iter=0; iter<2; ++iter)
2528 {
2529 5748864 int32_t checkflag=0;
2530
2531
2/2
✓ Branch 0 taken 2874432 times.
✓ Branch 1 taken 2874432 times.
5748864 if(iter==0)
2532 {
2533 2874432 checkflag=combobuf[tmpscr->data[i]].flag;
2534 2874432 }
2535 else
2536 {
2537 2874432 checkflag=tmpscr->sflag[i];
2538 }
2539
2540
2/2
✓ Branch 0 taken 5747766 times.
✓ Branch 1 taken 1098 times.
5748864 if(checkflag==mfSTRIKE)
2541 {
2542
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 906 times.
1098 if(!hints)
2543 {
2544
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 906 times.
906 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSTRIKE],tmpscr->secretcset[sSTRIKE]);
2545 906 }
2546 else
2547 {
2548 192 checkflag = strike_hint;
2549 }
2550 1098 }
2551
2552
20/36
✓ Branch 0 taken 5706470 times.
✓ Branch 1 taken 3148 times.
✓ Branch 2 taken 3618 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2064 times.
✓ Branch 5 taken 28640 times.
✓ Branch 6 taken 2418 times.
✓ Branch 7 taken 504 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 814 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✓ Branch 14 taken 33 times.
✓ Branch 15 taken 96 times.
✓ Branch 16 taken 24 times.
✓ Branch 17 taken 5 times.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 16 times.
✓ Branch 22 taken 16 times.
✓ Branch 23 taken 7 times.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✓ Branch 27 taken 16 times.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✓ Branch 31 taken 17 times.
✓ Branch 32 taken 35 times.
✓ Branch 33 taken 17 times.
✗ Branch 34 not taken.
✓ Branch 35 taken 906 times.
5748864 switch(checkflag)
2553 {
2554 case 0:
2555 case mfZELDA:
2556 case mfPUSHED:
2557 case mfENEMY0:
2558 case mfENEMY1:
2559 case mfENEMY2:
2560 case mfENEMY3:
2561 case mfENEMY4:
2562 case mfENEMY5:
2563 case mfENEMY6:
2564 case mfENEMY7:
2565 case mfENEMY8:
2566 case mfENEMY9:
2567 case mfSINGLE:
2568 case mfSINGLE16:
2569 case mfNOENEMY:
2570 case mfTRAP_H:
2571 case mfTRAP_V:
2572 case mfTRAP_4:
2573 case mfTRAP_LR:
2574 case mfTRAP_UD:
2575 case mfNOGROUNDENEMY:
2576 case mfNOBLOCKS:
2577 case mfSCRIPT1:
2578 case mfSCRIPT2:
2579 case mfSCRIPT3:
2580 case mfSCRIPT4:
2581 case mfSCRIPT5:
2582 case mfSCRIPT6:
2583 case mfSCRIPT7:
2584 case mfSCRIPT8:
2585 case mfSCRIPT9:
2586 case mfSCRIPT10:
2587 case mfSCRIPT11:
2588 case mfSCRIPT12:
2589 case mfSCRIPT13:
2590 case mfSCRIPT14:
2591 case mfSCRIPT15:
2592 case mfSCRIPT16:
2593 case mfSCRIPT17:
2594 case mfSCRIPT18:
2595 case mfSCRIPT19:
2596 case mfSCRIPT20:
2597 case mfPITHOLE:
2598 case mfPITFALLFLOOR:
2599 case mfLAVA:
2600 case mfICE:
2601 case mfICEDAMAGE:
2602 case mfDAMAGE1:
2603 case mfDAMAGE2:
2604 case mfDAMAGE4:
2605 case mfDAMAGE8:
2606 case mfDAMAGE16:
2607 case mfDAMAGE32:
2608 case mfFREEZEALL:
2609 case mfFREZEALLANSFFCS:
2610 case mfFREEZEFFCSOLY:
2611 case mfSCRITPTW1TRIG:
2612 case mfSCRITPTW2TRIG:
2613 case mfSCRITPTW3TRIG:
2614 case mfSCRITPTW4TRIG:
2615 case mfSCRITPTW5TRIG:
2616 case mfSCRITPTW6TRIG:
2617 case mfSCRITPTW7TRIG:
2618 case mfSCRITPTW8TRIG:
2619 case mfSCRITPTW9TRIG:
2620 case mfSCRITPTW10TRIG:
2621 case mfTROWEL:
2622 case mfTROWELNEXT:
2623 case mfTROWELSPECIALITEM:
2624 case mfSLASHPOT:
2625 case mfLIFTPOT:
2626 case mfLIFTORSLASH:
2627 case mfLIFTROCK:
2628 case mfLIFTROCKHEAVY:
2629 case mfDROPITEM:
2630 case mfSPECIALITEM:
2631 case mfDROPKEY:
2632 case mfDROPLKEY:
2633 case mfDROPCOMPASS:
2634 case mfDROPMAP:
2635 case mfDROPBOSSKEY:
2636 case mfSPAWNNPC:
2637 case mfSWITCHHOOK:
2638 case mfSIDEVIEWLADDER:
2639 case mfSIDEVIEWPLATFORM:
2640 case mfNOENEMYSPAWN:
2641 case mfENEMYALL:
2642 case mfNOMIRROR:
2643 case mfUNSAFEGROUND:
2644 case mf168:
2645 case mf169:
2646 case mf170:
2647 case mf171:
2648 case mf172:
2649 case mf173:
2650 case mf174:
2651 case mf175:
2652 case mf176:
2653 case mf177:
2654 case mf178:
2655 case mf179:
2656 case mf180:
2657 case mf181:
2658 case mf182:
2659 case mf183:
2660 case mf184:
2661 case mf185:
2662 case mf186:
2663 case mf187:
2664 case mf188:
2665 case mf189:
2666 case mf190:
2667 case mf191:
2668 case mf192:
2669 case mf193:
2670 case mf194:
2671 case mf195:
2672 case mf196:
2673 case mf197:
2674 case mf198:
2675 case mf199:
2676 case mf200:
2677 case mf201:
2678 case mf202:
2679 case mf203:
2680 case mf204:
2681 case mf205:
2682 case mf206:
2683 case mf207:
2684 case mf208:
2685 case mf209:
2686 case mf210:
2687 case mf211:
2688 case mf212:
2689 case mf213:
2690 case mf214:
2691 case mf215:
2692 case mf216:
2693 case mf217:
2694 case mf218:
2695 case mf219:
2696 case mf220:
2697 case mf221:
2698 case mf222:
2699 case mf223:
2700 case mf224:
2701 case mf225:
2702 case mf226:
2703 case mf227:
2704 case mf228:
2705 case mf229:
2706 case mf230:
2707 case mf231:
2708 case mf232:
2709 case mf233:
2710 case mf234:
2711 case mf235:
2712 case mf236:
2713 case mf237:
2714 case mf238:
2715 case mf239:
2716 case mf240:
2717 case mf241:
2718 case mf242:
2719 case mf243:
2720 case mf244:
2721 case mf245:
2722 case mf246:
2723 case mf247:
2724 case mf248:
2725 case mf249:
2726 case mf250:
2727 case mf251:
2728 case mf252:
2729 case mf253:
2730 case mf254:
2731 case mfEXTENDED:
2732 5706470 break;
2733
2734 case mfPUSHUD:
2735 case mfPUSHLR:
2736 case mfPUSH4:
2737 case mfPUSHU:
2738 case mfPUSHD:
2739 case mfPUSHL:
2740 case mfPUSHR:
2741 case mfPUSHUDNS:
2742 case mfPUSHLRNS:
2743 case mfPUSH4NS:
2744 case mfPUSHUNS:
2745 case mfPUSHDNS:
2746 case mfPUSHLNS:
2747 case mfPUSHRNS:
2748 case mfPUSHUDINS:
2749 case mfPUSHLRINS:
2750 case mfPUSH4INS:
2751 case mfPUSHUINS:
2752 case mfPUSHDINS:
2753 case mfPUSHLINS:
2754 case mfPUSHRINS:
2755
3/4
✓ Branch 0 taken 1829 times.
✓ Branch 1 taken 1319 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1829 times.
3148 if(!hints && ((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&16))
2756
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1829 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1829 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1829 || ((get_debug() && zc_getkey(KEY_N)) && (frame&16))))
2757 {
2758 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->undercombo,tmpscr->undercset);
2759 }
2760
2761
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3148 times.
3148 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2762
3/6
✓ Branch 0 taken 2438 times.
✓ Branch 1 taken 710 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 710 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3148 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2763 {
2764
2/2
✓ Branch 0 taken 1406 times.
✓ Branch 1 taken 1032 times.
2438 if(hints)
2765 {
2766
3/3
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 63 times.
✓ Branch 2 taken 897 times.
1032 switch(combobuf[tmpscr->data[i]].type)
2767 {
2768 case cPUSH_HEAVY:
2769 case cPUSH_HW:
2770 72 tempitem=getItemIDPower(itemsbuf,itype_bracelet,1);
2771 72 tempitemx=x, tempitemy=y;
2772
2773
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 72 times.
72 if(tempitem>-1)
2774 72 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2775
2776 72 break;
2777
2778 case cPUSH_HEAVY2:
2779 case cPUSH_HW2:
2780 63 tempitem=getItemIDPower(itemsbuf,itype_bracelet,2);
2781 63 tempitemx=x, tempitemy=y;
2782
2783
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63 times.
63 if(tempitem>-1)
2784 63 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2785
2786 63 break;
2787 }
2788 1032 }
2789 2438 }
2790
2791 3148 break;
2792
2793 case mfWHISTLE:
2794
1/2
✓ Branch 0 taken 2418 times.
✗ Branch 1 not taken.
2418 if(hints)
2795 {
2796 tempitem=getItemID(itemsbuf,itype_whistle,1);
2797
2798 if(tempitem<0) break;
2799
2800 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2801 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2802 {
2803 tempitemx=x;
2804 tempitemy=y;
2805 }
2806
2807 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2808 }
2809
2810 2418 break;
2811
2812 //Why is this here?
2813 case mfFAIRY:
2814 case mfMAGICFAIRY:
2815 case mfALLFAIRY:
2816 if(hints)
2817 {
2818 tempitem=getItemID(itemsbuf, itype_fairy,1);//iFairyMoving;
2819
2820 if(tempitem < 0) break;
2821
2822 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2823 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2824 {
2825 tempitemx=x;
2826 tempitemy=y;
2827 }
2828
2829 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2830 }
2831
2832 break;
2833
2834 case mfBCANDLE:
2835
2/2
✓ Branch 0 taken 252 times.
✓ Branch 1 taken 252 times.
504 if(!hints)
2836 {
2837
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 252 times.
252 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBCANDLE],tmpscr->secretcset[sBCANDLE]);
2838 252 }
2839 else
2840 {
2841 252 tempitem=getItemID(itemsbuf,itype_candle,1);
2842
2843
1/2
✓ Branch 0 taken 252 times.
✗ Branch 1 not taken.
252 if(tempitem<0) break;
2844
2845
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 252 times.
252 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2846
3/6
✓ Branch 0 taken 189 times.
✓ Branch 1 taken 63 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 63 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
252 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2847 {
2848 189 tempitemx=x;
2849 189 tempitemy=y;
2850 189 }
2851
2852 252 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2853 }
2854
2855 504 break;
2856
2857 case mfRCANDLE:
2858 if(!hints)
2859 {
2860 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sRCANDLE],tmpscr->secretcset[sRCANDLE]);
2861 }
2862 else
2863 {
2864 tempitem=getItemID(itemsbuf,itype_candle,2);
2865
2866 if(tempitem<0) break;
2867
2868 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2869 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2870 {
2871 tempitemx=x;
2872 tempitemy=y;
2873 }
2874
2875 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2876 }
2877
2878 break;
2879
2880 case mfWANDFIRE:
2881 if(!hints)
2882 {
2883 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWANDFIRE],tmpscr->secretcset[sWANDFIRE]);
2884 }
2885 else
2886 {
2887 tempitem=getItemID(itemsbuf,itype_wand,1);
2888
2889 if(tempitem<0) break;
2890
2891 tempweapon=wFire;
2892
2893 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2894 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2895 {
2896 tempitemx=x;
2897 tempitemy=y;
2898 }
2899 else
2900 {
2901 tempweaponx=x;
2902 tempweapony=y;
2903 }
2904
2905 putweapon(dest,tempweaponx,tempweapony,tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
2906 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2907 }
2908
2909 break;
2910
2911 case mfDINSFIRE:
2912 if(!hints)
2913 {
2914 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sDINSFIRE],tmpscr->secretcset[sDINSFIRE]);
2915 }
2916 else
2917 {
2918 tempitem=getItemID(itemsbuf,itype_dinsfire,1);
2919
2920 if(tempitem<0) break;
2921
2922 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2923 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2924 {
2925 tempitemx=x;
2926 tempitemy=y;
2927 }
2928
2929 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2930 }
2931
2932 break;
2933
2934 case mfARROW:
2935
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 732 times.
814 if(!hints)
2936 {
2937
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 732 times.
732 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sARROW],tmpscr->secretcset[sARROW]);
2938 732 }
2939 else
2940 {
2941 82 tempitem=getItemID(itemsbuf,itype_arrow,1);
2942
2943
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 if(tempitem<0) break;
2944
2945
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
82 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2946
3/6
✓ Branch 0 taken 61 times.
✓ Branch 1 taken 21 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 21 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
82 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2947 {
2948 61 tempitemx=x;
2949 61 tempitemy=y;
2950 61 }
2951
2952 82 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2953 }
2954
2955 814 break;
2956
2957 case mfSARROW:
2958 if(!hints)
2959 {
2960 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSARROW],tmpscr->secretcset[sSARROW]);
2961 }
2962 else
2963 {
2964 tempitem=getItemID(itemsbuf,itype_arrow,2);
2965
2966 if(tempitem<0) break;
2967
2968 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2969 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2970 {
2971 tempitemx=x;
2972 tempitemy=y;
2973 }
2974
2975 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2976 }
2977
2978 break;
2979
2980 case mfGARROW:
2981 if(!hints)
2982 {
2983 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sGARROW],tmpscr->secretcset[sGARROW]);
2984 }
2985 else
2986 {
2987 tempitem=getItemID(itemsbuf,itype_arrow,3);
2988
2989 if(tempitem<0) break;
2990
2991 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2992 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2993 {
2994 tempitemx=x;
2995 tempitemy=y;
2996 }
2997
2998 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2999 }
3000
3001 break;
3002
3003 case mfBOMB:
3004
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 16 times.
33 if(!hints)
3005 {
3006
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBOMB],tmpscr->secretcset[sBOMB]);
3007 16 }
3008 else
3009 {
3010 //tempitem=getItemID(itemsbuf,itype_bomb,1);
3011 17 tempweapon = wLitBomb;
3012
3013 //if (tempitem<0) break;
3014
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3015
3/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3016 {
3017 12 tempweaponx=x;
3018 12 tempweapony=y;
3019 12 }
3020
3021 17 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3022 }
3023
3024 33 break;
3025
3026 case mfSBOMB:
3027
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 48 times.
96 if(!hints)
3028 {
3029
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSBOMB],tmpscr->secretcset[sSBOMB]);
3030 48 }
3031 else
3032 {
3033 //tempitem=getItemID(itemsbuf,itype_sbomb,1);
3034 //if (tempitem<0) break;
3035 48 tempweapon = wLitSBomb;
3036
3037
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3038
3/6
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
48 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3039 {
3040 36 tempweaponx=x;
3041 36 tempweapony=y;
3042 36 }
3043
3044 48 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3045 }
3046
3047 96 break;
3048
3049 case mfARMOS_SECRET:
3050
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 12 times.
24 if(!hints)
3051 {
3052
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSTAIRS],tmpscr->secretcset[sSTAIRS]);
3053 12 }
3054 24 break;
3055
3056 case mfBRANG:
3057
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(!hints)
3058 {
3059 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBRANG],tmpscr->secretcset[sBRANG]);
3060 }
3061 else
3062 {
3063 5 tempitem=getItemID(itemsbuf,itype_brang,1);
3064
3065
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(tempitem<0) break;
3066
3067
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3068
3/6
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
5 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3069 {
3070 4 tempitemx=x;
3071 4 tempitemy=y;
3072 4 }
3073
3074 5 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3075 }
3076
3077 5 break;
3078
3079 case mfMBRANG:
3080 if(!hints)
3081 {
3082 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMBRANG],tmpscr->secretcset[sMBRANG]);
3083 }
3084 else
3085 {
3086 tempitem=getItemID(itemsbuf,itype_brang,2);
3087
3088 if(tempitem<0) break;
3089
3090 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3091 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3092 {
3093 tempitemx=x;
3094 tempitemy=y;
3095 }
3096
3097 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3098 }
3099
3100 break;
3101
3102 case mfFBRANG:
3103 if(!hints)
3104 {
3105 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sFBRANG],tmpscr->secretcset[sFBRANG]);
3106 }
3107 else
3108 {
3109 tempitem=getItemID(itemsbuf,itype_brang,3);
3110
3111 if(tempitem<0) break;
3112
3113 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3114 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3115 {
3116 tempitemx=x;
3117 tempitemy=y;
3118 }
3119
3120 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3121 }
3122
3123 break;
3124
3125 case mfWANDMAGIC:
3126 if(!hints)
3127 {
3128 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWANDMAGIC],tmpscr->secretcset[sWANDMAGIC]);
3129 }
3130 else
3131 {
3132 tempitem=getItemID(itemsbuf,itype_wand,1);
3133
3134 if(tempitem<0) break;
3135
3136 tempweapon=itemsbuf[tempitem].wpn3;
3137
3138 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3139 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3140 {
3141 tempitemx=x;
3142 tempitemy=y;
3143 }
3144 else
3145 {
3146 tempweaponx=x;
3147 tempweapony=y;
3148 --lens_hint_weapon[wMagic][4];
3149
3150 if(lens_hint_weapon[wMagic][4]<-8)
3151 {
3152 lens_hint_weapon[wMagic][4]=8;
3153 }
3154 }
3155
3156 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3157 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3158 }
3159
3160 break;
3161
3162 case mfREFMAGIC:
3163
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!hints)
3164 {
3165 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sREFMAGIC],tmpscr->secretcset[sREFMAGIC]);
3166 }
3167 else
3168 {
3169 16 tempitem=getItemID(itemsbuf,itype_shield,3);
3170
3171
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(tempitem<0) break;
3172
3173 16 tempweapon=ewMagic;
3174
3175
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3176
3/6
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3177 {
3178 13 tempitemx=x;
3179 13 tempitemy=y;
3180 13 }
3181 else
3182 {
3183 3 tempweaponx=x;
3184 3 tempweapony=y;
3185
3186
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1 times.
3 if(lens_hint_weapon[ewMagic][2]==up)
3187 {
3188 1 --lens_hint_weapon[ewMagic][4];
3189 1 }
3190 else
3191 {
3192 2 ++lens_hint_weapon[ewMagic][4];
3193 }
3194
3195
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(lens_hint_weapon[ewMagic][4]>8)
3196 {
3197 lens_hint_weapon[ewMagic][2]=up;
3198 }
3199
3200
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 2 times.
3 if(lens_hint_weapon[ewMagic][4]<=0)
3201 {
3202 2 lens_hint_weapon[ewMagic][2]=down;
3203 2 }
3204 }
3205
3206 16 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3207 16 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, lens_hint_weapon[ewMagic][2], lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3208 }
3209
3210 16 break;
3211
3212 case mfREFFIREBALL:
3213
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!hints)
3214 {
3215 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sREFFIREBALL],tmpscr->secretcset[sREFFIREBALL]);
3216 }
3217 else
3218 {
3219 16 tempitem=getItemID(itemsbuf,itype_shield,3);
3220
3221
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(tempitem<0) break;
3222
3223 16 tempweapon=ewFireball;
3224
3225
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3226
3/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3227 {
3228 12 tempitemx=x;
3229 12 tempitemy=y;
3230 12 tempweaponx=x;
3231 12 tempweapony=y;
3232 12 ++lens_hint_weapon[ewFireball][3];
3233
3234
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 1 times.
12 if(lens_hint_weapon[ewFireball][3]>8)
3235 {
3236 1 lens_hint_weapon[ewFireball][3]=-8;
3237 1 lens_hint_weapon[ewFireball][4]=8;
3238 1 }
3239
3240
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 4 times.
12 if(lens_hint_weapon[ewFireball][3]>0)
3241 {
3242 8 ++lens_hint_weapon[ewFireball][4];
3243 8 }
3244 else
3245 {
3246 4 --lens_hint_weapon[ewFireball][4];
3247 }
3248 12 }
3249
3250 16 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3251 16 putweapon(dest,tempweaponx+lens_hint_weapon[tempweapon][3],tempweapony+lens_hint_weapon[ewFireball][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3252 }
3253
3254 16 break;
3255
3256 case mfSWORD:
3257
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(!hints)
3258 {
3259 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSWORD],tmpscr->secretcset[sSWORD]);
3260 }
3261 else
3262 {
3263 7 tempitem=getItemID(itemsbuf,itype_sword,1);
3264
3265
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(tempitem<0) break;
3266
3267
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3268
3/6
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
7 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3269 {
3270 5 tempitemx=x;
3271 5 tempitemy=y;
3272 5 }
3273
3274 7 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3275 }
3276
3277 7 break;
3278
3279 case mfWSWORD:
3280 if(!hints)
3281 {
3282 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWSWORD],tmpscr->secretcset[sWSWORD]);
3283 }
3284 else
3285 {
3286 tempitem=getItemID(itemsbuf,itype_sword,2);
3287
3288 if(tempitem<0) break;
3289
3290 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3291 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3292 {
3293 tempitemx=x;
3294 tempitemy=y;
3295 }
3296
3297 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3298 }
3299
3300 break;
3301
3302 case mfMSWORD:
3303 if(!hints)
3304 {
3305 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMSWORD],tmpscr->secretcset[sMSWORD]);
3306 }
3307 else
3308 {
3309 tempitem=getItemID(itemsbuf,itype_sword,3);
3310
3311 if(tempitem<0) break;
3312
3313 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3314 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3315 {
3316 tempitemx=x;
3317 tempitemy=y;
3318 }
3319
3320 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3321 }
3322
3323 break;
3324
3325 case mfXSWORD:
3326 if(!hints)
3327 {
3328 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sXSWORD],tmpscr->secretcset[sXSWORD]);
3329 }
3330 else
3331 {
3332 tempitem=getItemID(itemsbuf,itype_sword,4);
3333
3334 if(tempitem<0) break;
3335
3336 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3337 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3338 {
3339 tempitemx=x;
3340 tempitemy=y;
3341 }
3342
3343 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3344 }
3345
3346 break;
3347
3348 case mfSWORDBEAM:
3349
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!hints)
3350 {
3351 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSWORDBEAM],tmpscr->secretcset[sSWORDBEAM]);
3352 }
3353 else
3354 {
3355 16 tempitem=getItemID(itemsbuf,itype_sword,1);
3356
3357
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(tempitem<0) break;
3358
3359
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3360
3/6
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3361 {
3362 11 tempitemx=x;
3363 11 tempitemy=y;
3364 11 }
3365
3366 16 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 1);
3367 }
3368
3369 16 break;
3370
3371 case mfWSWORDBEAM:
3372 if(!hints)
3373 {
3374 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWSWORDBEAM],tmpscr->secretcset[sWSWORDBEAM]);
3375 }
3376 else
3377 {
3378 tempitem=getItemID(itemsbuf,itype_sword,2);
3379
3380 if(tempitem<0) break;
3381
3382 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3383 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3384 {
3385 tempitemx=x;
3386 tempitemy=y;
3387 }
3388
3389 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 2);
3390 }
3391
3392 break;
3393
3394 case mfMSWORDBEAM:
3395 if(!hints)
3396 {
3397 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMSWORDBEAM],tmpscr->secretcset[sMSWORDBEAM]);
3398 }
3399 else
3400 {
3401 tempitem=getItemID(itemsbuf,itype_sword,3);
3402
3403 if(tempitem<0) break;
3404
3405 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3406 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3407 {
3408 tempitemx=x;
3409 tempitemy=y;
3410 }
3411
3412 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 3);
3413 }
3414
3415 break;
3416
3417 case mfXSWORDBEAM:
3418 if(!hints)
3419 {
3420 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sXSWORDBEAM],tmpscr->secretcset[sXSWORDBEAM]);
3421 }
3422 else
3423 {
3424 tempitem=getItemID(itemsbuf,itype_sword,4);
3425
3426 if(tempitem<0) break;
3427
3428 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3429 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3430 {
3431 tempitemx=x;
3432 tempitemy=y;
3433 }
3434
3435 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 4);
3436 }
3437
3438 break;
3439
3440 case mfHOOKSHOT:
3441
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!hints)
3442 {
3443 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sHOOKSHOT],tmpscr->secretcset[sHOOKSHOT]);
3444 }
3445 else
3446 {
3447 17 tempitem=getItemID(itemsbuf,itype_hookshot,1);
3448
3449
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(tempitem<0) break;
3450
3451
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3452
3/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3453 {
3454 12 tempitemx=x;
3455 12 tempitemy=y;
3456 12 }
3457
3458 17 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3459 }
3460
3461 17 break;
3462
3463 case mfWAND:
3464
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!hints)
3465 {
3466 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWAND],tmpscr->secretcset[sWAND]);
3467 }
3468 else
3469 {
3470 35 tempitem=getItemID(itemsbuf,itype_wand,1);
3471
3472
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(tempitem<0) break;
3473
3474
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3475
3/6
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
35 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3476 {
3477 28 tempitemx=x;
3478 28 tempitemy=y;
3479 28 }
3480
3481 35 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3482 }
3483
3484 35 break;
3485
3486 case mfHAMMER:
3487
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!hints)
3488 {
3489 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sHAMMER],tmpscr->secretcset[sHAMMER]);
3490 }
3491 else
3492 {
3493 17 tempitem=getItemID(itemsbuf,itype_hammer,1);
3494
3495
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(tempitem<0) break;
3496
3497
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3498
3/6
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3499 {
3500 13 tempitemx=x;
3501 13 tempitemy=y;
3502 13 }
3503
3504 17 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3505 }
3506
3507 17 break;
3508
3509 case mfARMOS_ITEM:
3510 case mfDIVE_ITEM:
3511
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2064 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2064 times.
2064 if((!getmapflag() || (tmpscr->flags9&fBELOWRETURN)) && !(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG3))
3512 {
3513 2064 putitem2(dest,x,y,tmpscr->catchall, lens_hint_item[tmpscr->catchall][0], lens_hint_item[tmpscr->catchall][1], 0);
3514 2064 }
3515 2064 break;
3516
3517 case 16:
3518 case 17:
3519 case 18:
3520 case 19:
3521 case 20:
3522 case 21:
3523 case 22:
3524 case 23:
3525 case 24:
3526 case 25:
3527 case 26:
3528 case 27:
3529 case 28:
3530 case 29:
3531 case 30:
3532 case 31:
3533
2/2
✓ Branch 0 taken 1008 times.
✓ Branch 1 taken 2610 times.
3618 if(!hints)
3534
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2610 times.
5220 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3535 2610 putcombo(dest,x,y,tmpscr->secretcombo[checkflag-16+4],tmpscr->secretcset[checkflag-16+4]);
3536
3537 3618 break;
3538 case mfSECRETSNEXT:
3539 if(!hints)
3540 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3541 putcombo(dest,x,y,tmpscr->data[i]+1,tmpscr->cset[i]);
3542
3543 break;
3544
3545 case mfSTRIKE:
3546
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 906 times.
906 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3547 {
3548 906 goto special;
3549 }
3550 else
3551 {
3552 break;
3553 }
3554
3555 28640 default: goto special;
3556
3557 special:
3558
8/8
✓ Branch 0 taken 14677 times.
✓ Branch 1 taken 14869 times.
✓ Branch 2 taken 473 times.
✓ Branch 3 taken 14204 times.
✓ Branch 4 taken 441 times.
✓ Branch 5 taken 32 times.
✓ Branch 6 taken 6108 times.
✓ Branch 7 taken 8128 times.
29546 if(layer && ((checkflag!=mfRAFT && checkflag!=mfRAFT_BRANCH&& checkflag!=mfRAFT_BOUNCE) ||(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG4)))
3559 {
3560
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 6549 times.
✓ Branch 2 taken 4913 times.
✓ Branch 3 taken 1636 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1636 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
6549 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate)) || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3561 {
3562 4913 rectfill(dest,x,y,x+15,y+15,WHITE);
3563 4913 }
3564 6549 }
3565
3566 29546 break;
3567 }
3568 5748864 }
3569 2874432 }
3570
3571
2/2
✓ Branch 0 taken 8166 times.
✓ Branch 1 taken 8166 times.
16332 if(layer)
3572 {
3573
2/2
✓ Branch 0 taken 7978 times.
✓ Branch 1 taken 188 times.
8166 if(tmpscr->door[0]==dWALK)
3574 188 rectfill(dest, 120, 16+playing_field_offset, 135, 31+playing_field_offset, WHITE);
3575
3576
2/2
✓ Branch 0 taken 7969 times.
✓ Branch 1 taken 197 times.
8166 if(tmpscr->door[1]==dWALK)
3577 197 rectfill(dest, 120, 144+playing_field_offset, 135, 159+playing_field_offset, WHITE);
3578
3579
2/2
✓ Branch 0 taken 8014 times.
✓ Branch 1 taken 152 times.
8166 if(tmpscr->door[2]==dWALK)
3580 152 rectfill(dest, 16, 80+playing_field_offset, 31, 95+playing_field_offset, WHITE);
3581
3582
2/2
✓ Branch 0 taken 7940 times.
✓ Branch 1 taken 226 times.
8166 if(tmpscr->door[3]==dWALK)
3583 226 rectfill(dest, 224, 80+playing_field_offset, 239, 95+playing_field_offset, WHITE);
3584
3585
2/2
✓ Branch 0 taken 8123 times.
✓ Branch 1 taken 43 times.
8166 if(tmpscr->door[0]==dBOMB)
3586 {
3587 43 showbombeddoor(dest, 0);
3588 43 }
3589
3590
2/2
✓ Branch 0 taken 8127 times.
✓ Branch 1 taken 39 times.
8166 if(tmpscr->door[1]==dBOMB)
3591 {
3592 39 showbombeddoor(dest, 1);
3593 39 }
3594
3595
1/2
✓ Branch 0 taken 8166 times.
✗ Branch 1 not taken.
8166 if(tmpscr->door[2]==dBOMB)
3596 {
3597 showbombeddoor(dest, 2);
3598 }
3599
3600
2/2
✓ Branch 0 taken 8129 times.
✓ Branch 1 taken 37 times.
8166 if(tmpscr->door[3]==dBOMB)
3601 {
3602 37 showbombeddoor(dest, 3);
3603 37 }
3604 8166 }
3605
3606
2/2
✓ Branch 0 taken 14298 times.
✓ Branch 1 taken 2034 times.
16332 if(tmpscr->stairx + tmpscr->stairy)
3607 {
3608
2/2
✓ Branch 0 taken 911 times.
✓ Branch 1 taken 1123 times.
2034 if(!hints)
3609 {
3610
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1123 times.
1123 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3611 1123 putcombo(dest,tmpscr->stairx,tmpscr->stairy+playing_field_offset,tmpscr->secretcombo[sSTAIRS],tmpscr->secretcset[sSTAIRS]);
3612 1123 }
3613 else
3614 {
3615
2/2
✓ Branch 0 taken 863 times.
✓ Branch 1 taken 48 times.
911 if(tmpscr->flags&fWHISTLE)
3616 {
3617 48 tempitem=getItemID(itemsbuf,itype_whistle,1);
3618 48 int32_t tempitemx=-16;
3619 48 int32_t tempitemy=-16;
3620
3621
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&(blink_rate/4)))
3622
3/6
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 24 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
48 || ((get_debug() && zc_getkey(KEY_N)) && (frame&(blink_rate/4))))
3623 {
3624 24 tempitemx=tmpscr->stairx;
3625 24 tempitemy=tmpscr->stairy+playing_field_offset;
3626 24 }
3627
3628 48 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3629 48 }
3630 }
3631 2034 }
3632 }
3633 16332 }
3634
3635 BITMAP *lens_scr_d; // The "d" is for "destructible"!
3636
3637 7997 void draw_lens_over()
3638 {
3639 // Oh, what the heck.
3640 static BITMAP *lens_scr = NULL;
3641 static int32_t last_width = -1;
3642 7997 int32_t width = itemsbuf[current_item_id(itype_lens,true)].misc1;
3643
3644 // Only redraw the circle if the size has changed
3645
2/2
✓ Branch 0 taken 7992 times.
✓ Branch 1 taken 5 times.
7997 if(width != last_width)
3646 {
3647
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(lens_scr == NULL)
3648 {
3649 5 lens_scr = create_bitmap_ex(8,2*288,2*(240-playing_field_offset));
3650 5 }
3651
3652 5 clear_to_color(lens_scr, BLACK);
3653 5 circlefill(lens_scr, 288, 240-playing_field_offset, width, 0);
3654 5 circle(lens_scr, 288, 240-playing_field_offset, width+2, 0);
3655 5 circle(lens_scr, 288, 240-playing_field_offset, width+5, 0);
3656 5 last_width=width;
3657 5 }
3658
3659 7997 masked_blit(lens_scr, framebuf, 288-(HeroX()+8), 240-playing_field_offset-(HeroY()+8), 0, playing_field_offset, 256, 168);
3660 7997 }
3661
3662 //----------------------------------------------------------------
3663
3664 30701 void draw_wavy(BITMAP *source, BITMAP *target, int32_t amplitude, bool interpol)
3665 {
3666 //recreating a big bitmap every frame is highly sluggish.
3667
4/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 30699 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
30701 static BITMAP *wavebuf = create_bitmap_ex(8,288,240-original_playing_field_offset);
3668 30701 clear_to_color(wavebuf, BLACK);
3669 30701 blit(source,wavebuf,0,original_playing_field_offset,16,0,256,224-original_playing_field_offset);
3670
3671 int32_t ofs;
3672 // int32_t amplitude=8;
3673 // int32_t wavelength=4;
3674
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30701 times.
30701 amplitude = zc_min(2048,amplitude); // some arbitrary limit to prevent crashing
3675
3/6
✓ Branch 0 taken 30701 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 30701 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 30701 times.
30701 if(flash_reduction_enabled() && !get_bit(quest_rules, qr_WAVY_NO_EPILEPSY)) amplitude = zc_min(16,amplitude);
3676 30701 int32_t amp2=168;
3677
2/4
✓ Branch 0 taken 30701 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 30701 times.
30701 if(flash_reduction_enabled() && !get_bit(quest_rules, qr_WAVY_NO_EPILEPSY_2)) amp2*=2;
3678 30701 int32_t i=frame%amp2;
3679
3680
2/2
✓ Branch 0 taken 5157768 times.
✓ Branch 1 taken 30701 times.
5188469 for(int32_t j=0; j<168; j++)
3681 {
3682
3/4
✓ Branch 0 taken 2578884 times.
✓ Branch 1 taken 2578884 times.
✓ Branch 2 taken 2578884 times.
✗ Branch 3 not taken.
5157768 if(j&1 && interpol)
3683 {
3684 // Add 288*2048 to ensure it's never negative. It'll get modded out.
3685 ofs=288*2048+int32_t(zc::math::Sin((double(i+j)*2*PI/amp2))*amplitude);
3686 }
3687 else
3688 {
3689 5157768 ofs=288*2048-int32_t(zc::math::Sin((double(i+j)*2*PI/amp2))*amplitude);
3690 }
3691
3692
1/2
✓ Branch 0 taken 5157768 times.
✗ Branch 1 not taken.
5157768 if(ofs)
3693 {
3694
2/2
✓ Branch 0 taken 1320388608 times.
✓ Branch 1 taken 5157768 times.
1325546376 for(int32_t k=0; k<256; k++)
3695 {
3696 1320388608 target->line[j+original_playing_field_offset][k]=wavebuf->line[j][(k+ofs+16)%288];
3697 1320388608 }
3698 5157768 }
3699 5157768 }
3700 30701 }
3701
3702 2832 void draw_fuzzy(int32_t fuzz)
3703 // draws from right half of scrollbuf to framebuf
3704 {
3705 int32_t firstx, firsty, xstep, ystep, i, y, dx, dy;
3706 byte *start, *si, *di;
3707
3708
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2832 times.
2832 if(fuzz<1)
3709 fuzz = 1;
3710
3711 2832 xstep = 128%fuzz;
3712
3713
2/2
✓ Branch 0 taken 590 times.
✓ Branch 1 taken 2242 times.
2832 if(xstep > 0)
3714 2242 xstep = fuzz-xstep;
3715
3716 2832 ystep = 112%fuzz;
3717
3718
2/2
✓ Branch 0 taken 826 times.
✓ Branch 1 taken 2006 times.
2832 if(ystep > 0)
3719 2006 ystep = fuzz-ystep;
3720
3721 2832 firsty = 1;
3722
3723
2/2
✓ Branch 0 taken 2832 times.
✓ Branch 1 taken 102188 times.
105020 for(y=0; y<224;)
3724 {
3725 102188 start = &(scrollbuf->line[y][256]);
3726
3727
4/4
✓ Branch 0 taken 100772 times.
✓ Branch 1 taken 635784 times.
✓ Branch 2 taken 634368 times.
✓ Branch 3 taken 102188 times.
736556 for(dy=0; dy<ystep && dy+y<224; dy++)
3728 {
3729 634368 si = start;
3730 634368 di = &(framebuf->line[y+dy][0]);
3731 634368 i = xstep;
3732 634368 firstx = 1;
3733
3734
2/2
✓ Branch 0 taken 162398208 times.
✓ Branch 1 taken 634368 times.
163032576 for(dx=0; dx<256; dx++)
3735 {
3736 162398208 *(di++) = *si;
3737
3738
2/2
✓ Branch 0 taken 136838464 times.
✓ Branch 1 taken 25559744 times.
162398208 if(++i >= fuzz)
3739 {
3740
2/2
✓ Branch 0 taken 24925376 times.
✓ Branch 1 taken 634368 times.
25559744 if(!firstx)
3741 24925376 si += fuzz;
3742 else
3743 {
3744 634368 si += fuzz-xstep;
3745 634368 firstx = 0;
3746 }
3747
3748 25559744 i = 0;
3749 25559744 }
3750 162398208 }
3751 634368 }
3752
3753
2/2
✓ Branch 0 taken 99356 times.
✓ Branch 1 taken 2832 times.
102188 if(!firsty)
3754 99356 y += fuzz;
3755 else
3756 {
3757 2832 y += ystep;
3758 2832 ystep = fuzz;
3759 2832 firsty = 0;
3760 }
3761 }
3762 2832 }
3763
3764 6510665 void updatescr(bool allowwavy)
3765 {
3766
4/6
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 6510636 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 29 times.
✓ Branch 4 taken 29 times.
✗ Branch 5 not taken.
6510665 static BITMAP *wavybuf = create_bitmap_ex(8,256,224);
3767
4/6
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 6510636 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 29 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 29 times.
6510665 static BITMAP *panorama = create_bitmap_ex(8,256,224);
3768
3769
2/2
✓ Branch 0 taken 6484961 times.
✓ Branch 1 taken 25704 times.
6510665 if(toogam)
3770 {
3771 25704 textout_ex(framebuf,font,"no walls",8,216,1,-1);
3772 25704 }
3773
3774
1/2
✓ Branch 0 taken 6510665 times.
✗ Branch 1 not taken.
6510665 if(Showpal)
3775 dump_pal(framebuf);
3776
3777
2/2
✓ Branch 0 taken 6428643 times.
✓ Branch 1 taken 82022 times.
6510665 if(!Playing)
3778 82022 black_opening_count=0;
3779
3780
2/2
✓ Branch 0 taken 6472715 times.
✓ Branch 1 taken 37950 times.
6510665 if(black_opening_count<0) //shape is opening up
3781 {
3782 37950 black_opening(framebuf,black_opening_x,black_opening_y,(66+black_opening_count),66);
3783
3784
2/4
✓ Branch 0 taken 37950 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 37950 times.
37950 if(Advance||(!Paused))
3785 {
3786 37950 ++black_opening_count;
3787 37950 }
3788 37950 }
3789
2/2
✓ Branch 0 taken 6458459 times.
✓ Branch 1 taken 14256 times.
6472715 else if(black_opening_count>0) //shape is closing
3790 {
3791 14256 black_opening(framebuf,black_opening_x,black_opening_y,black_opening_count,66);
3792
3793
2/4
✓ Branch 0 taken 14256 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14256 times.
14256 if(Advance||(!Paused))
3794 {
3795 14256 --black_opening_count;
3796 14256 }
3797 14256 }
3798
3799
3/4
✓ Branch 0 taken 6459250 times.
✓ Branch 1 taken 51415 times.
✓ Branch 2 taken 6459250 times.
✗ Branch 3 not taken.
6510665 if(black_opening_count==0&&black_opening_shape==bosFADEBLACK)
3800 {
3801 black_opening_shape = bosCIRCLE;
3802 memcpy(RAMpal, tempblackpal, PAL_SIZE*sizeof(RGB));
3803 refreshTints();
3804 refreshpal=true;
3805 }
3806
3807
2/2
✓ Branch 0 taken 6298112 times.
✓ Branch 1 taken 212553 times.
6510665 if(refreshpal)
3808 {
3809 212553 refreshpal=false;
3810 212553 RAMpal[253] = _RGB(0,0,0);
3811 212553 RAMpal[254] = _RGB(63,63,63);
3812 212553 hw_palette = &RAMpal;
3813 212553 update_hw_pal = true;
3814
3815 212553 create_rgb_table(&rgb_table, RAMpal, NULL);
3816 212553 create_zc_trans_table(&trans_table, RAMpal, 128, 128, 128);
3817 212553 memcpy(&trans_table2, &trans_table, sizeof(COLOR_MAP));
3818
3819
2/2
✓ Branch 0 taken 54413568 times.
✓ Branch 1 taken 212553 times.
54626121 for(int32_t q=0; q<PAL_SIZE; q++)
3820 {
3821 54413568 trans_table2.data[0][q] = q;
3822 54413568 trans_table2.data[q][q] = q;
3823 54413568 }
3824 212553 }
3825
3826 6510665 bool clearwavy = (wavy <= 0);
3827
3828
2/2
✓ Branch 0 taken 7245 times.
✓ Branch 1 taken 6503420 times.
6510665 if(wavy <= 0)
3829 {
3830 // So far one thing can alter wavy apart from scripts: Wavy DMaps.
3831 6503420 wavy = (DMaps[currdmap].flags&dmfWAVY ? 4 : 0);
3832 6503420 }
3833
3834 6510665 blit(framebuf, wavybuf, 0, 0, 0, 0, 256, 224);
3835
3836
6/6
✓ Branch 0 taken 30951 times.
✓ Branch 1 taken 6479714 times.
✓ Branch 2 taken 30829 times.
✓ Branch 3 taken 122 times.
✓ Branch 4 taken 128 times.
✓ Branch 5 taken 30701 times.
6510665 if(wavy && Playing && allowwavy)
3837 {
3838 30701 draw_wavy(framebuf, wavybuf, wavy,false);
3839 30701 }
3840
3841
2/2
✓ Branch 0 taken 6503420 times.
✓ Branch 1 taken 7245 times.
6510665 if(clearwavy)
3842 6503420 wavy = 0; // Wavy was set by a DMap flag. Clear it.
3843
2/4
✓ Branch 0 taken 7245 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7245 times.
7245 else if(Playing && !Paused)
3844 7245 wavy--; // Wavy was set by a script. Decrement it.
3845
3846
5/6
✓ Branch 0 taken 6428643 times.
✓ Branch 1 taken 82022 times.
✓ Branch 2 taken 125857 times.
✓ Branch 3 taken 6302786 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 125857 times.
6510665 if(Playing && msgpos && !screenscrolling)
3847 {
3848
1/2
✓ Branch 0 taken 125857 times.
✗ Branch 1 not taken.
125857 if(!(msg_bg_display_buf->clip))
3849 125857 blit_msgstr_bg(framebuf,0,0,0,playing_field_offset,256,168);
3850
1/2
✓ Branch 0 taken 125857 times.
✗ Branch 1 not taken.
125857 if(!(msg_portrait_display_buf->clip))
3851 125857 blit_msgstr_prt(framebuf,0,0,0,playing_field_offset,256,168);
3852
1/2
✓ Branch 0 taken 125857 times.
✗ Branch 1 not taken.
125857 if(!(msg_txt_display_buf->clip))
3853 125857 blit_msgstr_fg(framebuf,0,0,0,playing_field_offset,256,168);
3854 125857 }
3855
3856 /*
3857 if(!(msg_txt_display_buf->clip) && Playing && msgpos && !screenscrolling)
3858 {
3859 BITMAP* subBmp = 0;
3860 masked_blit(msg_txt_display_buf,subBmp,0,0,0,playing_field_offset,256,168);
3861 // masked_blit(msg_txt_display_buf,subBmp,0,playing_field_offset,256,168);
3862 draw_trans_sprite(framebuf, subBmp, 0, playing_field_offset);
3863 destroy_bitmap(subBmp);
3864 //void draw_sprite_ex(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t mode, int32_t flip);
3865 // masked_blit(msg_txt_display_buf,framebuf,0,0,0,playing_field_offset,256,168);
3866 //void masked_blit(BITMAP *source, BITMAP *dest, int32_t source_x, int32_t source_y, int32_t dest_x, int32_t dest_y, int32_t width, int32_t height);
3867 }
3868 */
3869
3870
2/2
✓ Branch 0 taken 6485486 times.
✓ Branch 1 taken 25179 times.
6510665 bool nosubscr = (tmpscr->flags3&fNOSUBSCR && !(tmpscr->flags3&fNOSUBSCROFFSET));
3871
3872
2/2
✓ Branch 0 taken 6485486 times.
✓ Branch 1 taken 25179 times.
6510665 if(nosubscr)
3873 {
3874 25179 rectfill(panorama,0,0,255,passive_subscreen_height/2,0);
3875 25179 rectfill(panorama,0,168+passive_subscreen_height/2,255,168+passive_subscreen_height-1,0);
3876 25179 blit(wavybuf,panorama,0,playing_field_offset,0,passive_subscreen_height/2,256,224-passive_subscreen_height);
3877 25179 }
3878
3879 //TODO: Optimize blit 'overcalls' -Gleeok
3880
2/2
✓ Branch 0 taken 25179 times.
✓ Branch 1 taken 6485486 times.
6510665 BITMAP *source = nosubscr ? panorama : wavybuf;
3881 6510665 blit(source,framebuf,0,0,0,0,256,224);
3882
3883 6510665 update_hw_screen();
3884 6510665 }
3885
3886 //----------------------------------------------------------------
3887
3888 PALETTE sys_pal;
3889
3890 int32_t onGUISnapshot()
3891 {
3892 char buf[200];
3893 int32_t num=0;
3894 bool realpal=(key[KEY_ZC_LCONTROL] || key[KEY_ZC_RCONTROL]);
3895 do
3896 {
3897 sprintf(buf, "%szc_screen%05d.%s", get_snap_str(), ++num, snapshotformat_str[SnapshotFormat][1]);
3898 }
3899 while(num<99999 && exists(buf));
3900
3901 BITMAP *b = create_bitmap_ex(8,resx,resy);
3902
3903 if(b)
3904 {
3905 if(MenuOpen)
3906 {
3907 //Cannot load game's palette while GUI elements are in focus. -Z
3908 //If there is a way to do this, then I have missed it.
3909 /*
3910 game_pal();
3911 RAMpal[253] = _RGB(0,0,0);
3912 RAMpal[254] = _RGB(63,63,63);
3913 zc_set_palette_range(RAMpal,0,255);
3914 memcpy(RAMpal, snappal, sizeof(snappal));
3915 create_rgb_table(&rgb_table, RAMpal, NULL);
3916 create_zc_trans_table(&trans_table, RAMpal, 128, 128, 128);
3917 memcpy(&trans_table2, &trans_table, sizeof(COLOR_MAP));
3918
3919 for(int32_t q=0; q<PAL_SIZE; q++)
3920 {
3921 trans_table2.data[0][q] = q;
3922 trans_table2.data[q][q] = q;
3923 }
3924 */
3925 //ringcolor(false);
3926 //get_palette(RAMpal);
3927 blit(screen,b,0,0,0,0,resx,resy);
3928 //al_trace("Menu Open\n");
3929 //game_pal();
3930 //PALETTE temppal;
3931 //get_palette(temppal);
3932 //system_pal();
3933 save_bitmap(buf,b,sys_pal);
3934 //save_bitmap(buf,b,RAMpal);
3935 //save_bitmap(buf,b,snappal);
3936 }
3937 else
3938 {
3939 blit(screen,b,0,0,0,0,resx,resy);
3940 save_bitmap(buf,b,realpal?sys_pal:RAMpal);
3941 }
3942 destroy_bitmap(b);
3943 }
3944
3945 return D_O_K;
3946 }
3947
3948 int32_t onNonGUISnapshot()
3949 {
3950 PALETTE temppal;
3951 get_palette(temppal);
3952 bool realpal=(zc_getkey(KEY_ZC_LCONTROL, true) || zc_getkey(KEY_ZC_RCONTROL, true));
3953
3954 char buf[200];
3955 int32_t num=0;
3956
3957 do
3958 {
3959 sprintf(buf, "%szc_screen%05d.%s", get_snap_str(), ++num, snapshotformat_str[SnapshotFormat][1]);
3960 }
3961 while(num<99999 && exists(buf));
3962
3963 save_bitmap(buf,framebuf,realpal?temppal:RAMpal);
3964
3965 return D_O_K;
3966 }
3967
3968 int32_t onSnapshot()
3969 {
3970 if(zc_getkey(KEY_LSHIFT, true)||zc_getkey(KEY_RSHIFT, true))
3971 {
3972 onGUISnapshot();
3973 }
3974 else
3975 {
3976 onNonGUISnapshot();
3977 }
3978
3979 return D_O_K;
3980 }
3981
3982 int32_t onSaveMapPic()
3983 {
3984 int32_t mapres2 = 0;
3985 char buf[200];
3986 int32_t num=0;
3987 mapscr tmpscr_b[2];
3988 mapscr tmpscr_c[6];
3989 BITMAP* _screen_draw_buffer = NULL;
3990 _screen_draw_buffer = create_bitmap_ex(8,256,224);
3991 set_clip_state(_screen_draw_buffer,1);
3992
3993 for(int32_t i=0; i<6; ++i)
3994 {
3995 tmpscr_c[i] = tmpscr2[i];
3996 tmpscr2[i].zero_memory();
3997
3998 if(i>=2)
3999 {
4000 continue;
4001 }
4002
4003 tmpscr_b[i] = tmpscr[i];
4004 tmpscr[i].zero_memory();
4005 }
4006
4007 do
4008 {
4009 sprintf(buf, "%szc_screen%05d.png", get_snap_str(), ++num);
4010 }
4011 while(num<99999 && exists(buf));
4012
4013 BITMAP* mappic = NULL;
4014
4015
4016 bool done=false, redraw=true;
4017
4018 mappic = create_bitmap_ex(8,(256*16)>>mapres,(176*8)>>mapres);
4019
4020 if(!mappic)
4021 {
4022 system_pal();
4023 jwin_alert("View Map","Not enough memory.",NULL,NULL,"OK",NULL,13,27,lfont);
4024 game_pal();
4025 return D_O_K;;
4026 }
4027
4028 // draw the map
4029 set_clip_rect(_screen_draw_buffer, 0, 0, _screen_draw_buffer->w, _screen_draw_buffer->h);
4030
4031 for(int32_t y=0; y<8; y++)
4032 {
4033 for(int32_t x=0; x<16; x++)
4034 {
4035 if(!displayOnMap(x, y))
4036 {
4037 rectfill(_screen_draw_buffer, 0, 0, 255, 223, WHITE);
4038 }
4039 else
4040 {
4041 int32_t s = (y<<4) + x;
4042 loadscr2(1,s,-1);
4043
4044 for(int32_t i=0; i<6; i++)
4045 {
4046 if(tmpscr[1].layermap[i]<=0)
4047 continue;
4048
4049 if((ZCMaps[tmpscr[1].layermap[i]-1].tileWidth==ZCMaps[currmap].tileWidth) &&
4050 (ZCMaps[tmpscr[1].layermap[i]-1].tileHeight==ZCMaps[currmap].tileHeight))
4051 {
4052 const int32_t _mapsSize = (ZCMaps[currmap].tileWidth)*(ZCMaps[currmap].tileHeight);
4053
4054 tmpscr2[i]=TheMaps[(tmpscr[1].layermap[i]-1)*MAPSCRS+tmpscr[1].layerscreen[i]];
4055 }
4056 }
4057
4058 if(XOR((tmpscr+1)->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(_screen_draw_buffer, 0, 2, tmpscr+1, -256, playing_field_offset, 2);
4059
4060 if(XOR((tmpscr+1)->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(_screen_draw_buffer, 0, 3, tmpscr+1, -256, playing_field_offset, 2);
4061
4062 putscr(_screen_draw_buffer,256,0,tmpscr+1);
4063 do_layer(_screen_draw_buffer, 0, 1, tmpscr+1, -256, playing_field_offset, 2);
4064
4065 if(!XOR((tmpscr+1)->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(_screen_draw_buffer, 0, 2, tmpscr+1, -256, playing_field_offset, 2);
4066
4067 putscrdoors(_screen_draw_buffer,256,0,tmpscr+1);
4068 do_layer(_screen_draw_buffer, -2, 0, tmpscr+1, -256, playing_field_offset, 2);
4069 if(get_bit(quest_rules, qr_PUSHBLOCK_LAYER_1_2))
4070 {
4071 do_layer(_screen_draw_buffer, -2, 1, tmpscr+1, -256, playing_field_offset, 2);
4072 do_layer(_screen_draw_buffer, -2, 2, tmpscr+1, -256, playing_field_offset, 2);
4073 }
4074 do_layer(_screen_draw_buffer, -3, 0, tmpscr+1, -256, playing_field_offset, 2); // Freeform combos!
4075
4076 if(!XOR((tmpscr+1)->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(_screen_draw_buffer, 0, 3, tmpscr+1, -256, playing_field_offset, 2);
4077
4078 do_layer(_screen_draw_buffer, 0, 4, tmpscr+1, -256, playing_field_offset, 2);
4079 do_layer(_screen_draw_buffer, -1, 0, tmpscr+1, -256, playing_field_offset, 2);
4080 if(get_bit(quest_rules, qr_OVERHEAD_COMBOS_L1_L2))
4081 {
4082 do_layer(_screen_draw_buffer, -1, 1, tmpscr+1, -256, playing_field_offset, 2);
4083 do_layer(_screen_draw_buffer, -1, 2, tmpscr+1, -256, playing_field_offset, 2);
4084 }
4085 do_layer(_screen_draw_buffer, 0, 5, tmpscr+1, -256, playing_field_offset, 2);
4086 do_layer(_screen_draw_buffer, 0, 6, tmpscr+1, -256, playing_field_offset, 2);
4087
4088 }
4089
4090 stretch_blit(_screen_draw_buffer, mappic, 256, 0, 256, 176, x<<(8-mapres), (y*176)>>mapres, 256>>mapres, 176>>mapres);
4091 }
4092 }
4093
4094 for(int32_t i=0; i<6; ++i)
4095 {
4096 tmpscr2[i]=tmpscr_c[i];
4097
4098 if(i>=2)
4099 {
4100 continue;
4101 }
4102
4103 tmpscr[i]=tmpscr_b[i];
4104 }
4105
4106 save_bitmap(buf,mappic,RAMpal);
4107 destroy_bitmap(mappic);
4108 destroy_bitmap(_screen_draw_buffer);
4109 return D_O_K;
4110 }
4111
4112 /*
4113 int32_t onSaveMapPic()
4114 {
4115 BITMAP* mappic = NULL;
4116 BITMAP* _screen_draw_buffer = NULL;
4117 _screen_draw_buffer = create_bitmap_ex(8,256,224);
4118 int32_t mapres2 = 0;
4119 char buf[20];
4120 int32_t num=0;
4121 set_clip_state(_screen_draw_buffer,1);
4122 set_clip_rect(_screen_draw_buffer,0,0,_screen_draw_buffer->w, _screen_draw_buffer->h);
4123
4124 do
4125 {
4126 sprintf(buf, "zelda%03d.png", ++num);
4127 }
4128 while(num<999 && exists(buf));
4129
4130 // if(!mappic) {
4131 mappic = create_bitmap_ex(8,(256*16)>>mapres2,(176*8)>>mapres2);
4132
4133 if(!mappic)
4134 {
4135 system_pal();
4136 jwin_alert("Save Map Picture","Not enough memory.",NULL,NULL,"OK",NULL,13,27,lfont);
4137 game_pal();
4138 return D_O_K;
4139 }
4140
4141 // }
4142
4143 int32_t layermap, layerscreen;
4144 int32_t x2=0;
4145
4146 // draw the map
4147 for(int32_t y=0; y<8; y++)
4148 {
4149 for(int32_t x=0; x<16; x++)
4150 {
4151 int32_t s = (y<<4) + x;
4152
4153 if(!displayOnMap(x, y))
4154 {
4155 rectfill(_screen_draw_buffer, 0, 0, 255, 223, WHITE);
4156 }
4157 else
4158 {
4159 loadscr(TEMPSCR_FUNCTION_SWAP_SPACE,currdmap,s,-1,false);
4160 putscr(_screen_draw_buffer, 0, 0, tmpscr+1);
4161
4162 for(int32_t k=0; k<4; k++)
4163 {
4164 if(k==2)
4165 {
4166 putscrdoors(_screen_draw_buffer, 0, 0, tmpscr+1);
4167 }
4168
4169 layermap=TheMaps[currmap*MAPSCRS+s].layermap[k]-1;
4170
4171 if(layermap>-1)
4172 {
4173 layerscreen=layermap*MAPSCRS+TheMaps[currmap*MAPSCRS+s].layerscreen[k];
4174
4175 if(TheMaps[currmap*MAPSCRS+s].layeropacity[k]==255)
4176 {
4177 for(int32_t i=0; i<176; i++)
4178 {
4179 overcombo(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),TheMaps[layerscreen].data[i],TheMaps[layerscreen].cset[i]);
4180 }
4181 }
4182 else
4183 {
4184 for(int32_t i=0; i<176; i++)
4185 {
4186 overcombotranslucent(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),TheMaps[layerscreen].data[i],TheMaps[layerscreen].cset[i],TheMaps[currmap*MAPSCRS+s].layeropacity[k]);
4187 }
4188 }
4189 }
4190 }
4191
4192 for(int32_t i=0; i<176; i++)
4193 {
4194 // if (COMBOTYPE((i&15)<<4,i&0xF0)==cOLD_OVERHEAD)
4195 if(combo_class_buf[COMBOTYPE((i&15)<<4,i&0xF0)].overhead)
4196 {
4197 overcombo(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),MAPCOMBO((i&15)<<4,i&0xF0),MAPCSET((i&15)<<4,i&0xF0));
4198 }
4199 }
4200
4201 for(int32_t k=4; k<6; k++)
4202 {
4203 layermap=TheMaps[currmap*MAPSCRS+s].layermap[k]-1;
4204
4205 if(layermap>-1)
4206 {
4207 layerscreen=layermap*MAPSCRS+TheMaps[currmap*MAPSCRS+s].layerscreen[k];
4208
4209 if(TheMaps[currmap*MAPSCRS+s].layeropacity[k]==255)
4210 {
4211 for(int32_t i=0; i<176; i++)
4212 {
4213 overcombo(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),TheMaps[layerscreen].data[i],TheMaps[layerscreen].cset[i]);
4214 }
4215 }
4216 else
4217 {
4218 for(int32_t i=0; i<176; i++)
4219 {
4220 overcombotranslucent(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),TheMaps[layerscreen].data[i],TheMaps[layerscreen].cset[i],TheMaps[currmap*MAPSCRS+s].layeropacity[k]);
4221 }
4222 }
4223 }
4224 }
4225 }
4226
4227 stretch_blit(_screen_draw_buffer, mappic, 0, 0, 256, 176,
4228 x<<(8-mapres2), (y*176)>>mapres2, 256>>mapres2, 176>>mapres2);
4229 }
4230
4231 }
4232
4233 save_bitmap(buf,mappic,RAMpal);
4234 destroy_bitmap(mappic);
4235 destroy_bitmap(_screen_draw_buffer);
4236 return D_O_K;
4237 }
4238 */
4239
4240 14 void f_Quit(int32_t type)
4241 {
4242
2/4
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
14 if(type==qQUIT && !Playing)
4243 return;
4244
4245 14 bool from_menu = is_sys_pal;
4246
4247
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(!from_menu)
4248 {
4249 14 music_pause();
4250 14 pause_all_sfx();
4251 14 }
4252 14 enter_sys_pal();
4253 14 clear_keybuf();
4254
4255
2/4
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14 times.
14 if (replay_is_active() && replay_get_version() <= 9)
4256 14 replay_poll();
4257
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if (replay_is_replaying())
4258 14 replay_peek_quit();
4259
4260
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if (!replay_is_replaying())
4261 switch(type)
4262 {
4263 case qQUIT:
4264 onQuit();
4265 break;
4266
4267 case qRESET:
4268 onReset();
4269 break;
4270
4271 case qEXIT:
4272 onExit();
4273 break;
4274 }
4275
4276
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if(Quit)
4277 {
4278 14 kill_sfx();
4279 14 music_stop();
4280 14 exit_sys_pal();
4281 14 update_hw_screen();
4282 14 }
4283 else
4284 {
4285 exit_sys_pal();
4286 if(!from_menu)
4287 {
4288 music_resume();
4289 resume_all_sfx();
4290 }
4291 }
4292
4293
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(!from_menu)
4294 14 show_mouse(NULL);
4295 14 eat_buttons();
4296
4297 14 zc_readrawkey(KEY_ESC);
4298
4299 14 zc_readrawkey(KEY_ENTER);
4300 14 }
4301
4302 //----------------------------------------------------------------
4303
4304 int32_t onNoWalls()
4305 {
4306 cheats_enqueue(Cheat::Walls);
4307 return D_O_K;
4308 }
4309
4310 int32_t onIgnoreSideview()
4311 {
4312 cheats_enqueue(Cheat::IgnoreSideView);
4313 return D_O_K;
4314 }
4315
4316 6510614 int32_t input_idle(bool checkmouse)
4317 {
4318 static int32_t mx, my, mz, mb;
4319
4320
4/6
✓ Branch 0 taken 6510614 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1621032 times.
✓ Branch 3 taken 4889582 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1621032 times.
8131646 if(keypressed() || zc_key_pressed() ||
4321
4/8
✓ Branch 0 taken 1621032 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1621032 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1621032 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1621032 times.
✗ Branch 7 not taken.
1621032 (checkmouse && (mx != mouse_x || my != mouse_y || mz != mouse_z || mb != mouse_b)))
4322 {
4323 4889582 idle_count = 0;
4324
4325
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4889582 times.
4889582 if(active_count < MAX_ACTIVE)
4326 {
4327 4889582 ++active_count;
4328 4889582 }
4329 4889582 }
4330
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1621032 times.
1621032 else if(idle_count < MAX_IDLE)
4331 {
4332 1621032 ++idle_count;
4333 1621032 active_count = 0;
4334 1621032 }
4335
4336 6510614 mx = mouse_x;
4337 6510614 my = mouse_y;
4338 6510614 mz = mouse_z;
4339 6510614 mb = mouse_b;
4340
4341 6510614 return idle_count;
4342 }
4343
4344 int32_t onGoFast()
4345 {
4346 cheats_enqueue(Cheat::Fast);
4347 return D_O_K;
4348 }
4349
4350 int32_t onKillCheat()
4351 {
4352 cheats_enqueue(Cheat::Kill);
4353 return D_O_K;
4354 }
4355
4356 int32_t onSecretsCheat()
4357 {
4358 cheats_enqueue(Cheat::TrigSecrets);
4359 return D_O_K;
4360 }
4361 int32_t onSecretsCheatPerm()
4362 {
4363 cheats_enqueue(Cheat::TrigSecretsPerm);
4364 return D_O_K;
4365 }
4366
4367 int32_t onShowLayer0()
4368 {
4369 show_layer_0 = !show_layer_0;
4370 return D_O_K;
4371 }
4372 int32_t onShowLayer1()
4373 {
4374 show_layer_1 = !show_layer_1;
4375 return D_O_K;
4376 }
4377 int32_t onShowLayer2()
4378 {
4379 show_layer_2 = !show_layer_2;
4380 return D_O_K;
4381 }
4382 int32_t onShowLayer3()
4383 {
4384 show_layer_3 = !show_layer_3;
4385 return D_O_K;
4386 }
4387 int32_t onShowLayer4()
4388 {
4389 show_layer_4 = !show_layer_4;
4390 return D_O_K;
4391 }
4392 int32_t onShowLayer5()
4393 {
4394 show_layer_5 = !show_layer_5;
4395 return D_O_K;
4396 }
4397 int32_t onShowLayer6()
4398 {
4399 show_layer_6 = !show_layer_6;
4400 return D_O_K;
4401 }
4402 int32_t onShowLayerO()
4403 {
4404 show_layer_over=!show_layer_over;
4405 return D_O_K;
4406 }
4407 int32_t onShowLayerP()
4408 {
4409 show_layer_push=!show_layer_push;
4410 return D_O_K;
4411 }
4412 int32_t onShowLayerS()
4413 {
4414 show_sprites=!show_sprites;
4415 return D_O_K;
4416 }
4417 int32_t onShowLayerF()
4418 {
4419 show_ffcs=!show_ffcs;
4420 return D_O_K;
4421 }
4422 int32_t onShowLayerW()
4423 {
4424 show_walkflags=!show_walkflags;
4425 if(show_walkflags)
4426 show_effectflags = false;
4427 return D_O_K;
4428 }
4429 int32_t onShowLayerE()
4430 {
4431 show_effectflags=!show_effectflags;
4432 if(show_effectflags)
4433 show_walkflags = false;
4434 return D_O_K;
4435 }
4436 int32_t onShowFFScripts()
4437 {
4438 show_ff_scripts=!show_ff_scripts;
4439 return D_O_K;
4440 }
4441 int32_t onShowHitboxes()
4442 {
4443 show_hitboxes=!show_hitboxes;
4444 return D_O_K;
4445 }
4446 int32_t onShowInfoOpacity()
4447 {
4448 info_opacity = vbound(getnumber("Debug Info Opacity",info_opacity),0,255);
4449 zc_set_config("zc","debug_info_opacity",info_opacity);
4450 return D_O_K;
4451 }
4452
4453 int32_t onLightSwitch()
4454 {
4455 cheats_enqueue(Cheat::Light);
4456 return D_O_K;
4457 }
4458
4459 int32_t onGoTo();
4460 int32_t onGoToComplete();
4461
4462 6510614 void syskeys()
4463 {
4464 6510614 update_system_keys();
4465
4466 int32_t oldtitle_version;
4467
4468
1/2
✓ Branch 0 taken 6510614 times.
✗ Branch 1 not taken.
6510614 if(close_button_quit)
4469 {
4470 close_button_quit=false;
4471 f_Quit(qEXIT);
4472 }
4473
4474 6510614 poll_joystick();
4475
4476
2/10
✓ Branch 0 taken 6510614 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6510614 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
6510614 if(rMbtn() || (gui_mouse_b() && !mouse_down && ClickToFreeze &&!disableClickToFreeze))
4477 {
4478 oldtitle_version=title_version;
4479 System();
4480 }
4481
4482 6510614 mouse_down=gui_mouse_b();
4483
4484
1/2
✓ Branch 0 taken 6510614 times.
✗ Branch 1 not taken.
6510614 if(zc_read_system_key(KEY_F1))
4485 {
4486 if(zc_get_system_key(KEY_ZC_LCONTROL) || zc_get_system_key(KEY_ZC_RCONTROL))
4487 {
4488 halt=!halt;
4489 //zinit.subscreen=(zinit.subscreen+1)%ssdtMAX;
4490 }
4491 else
4492 {
4493 Throttlefps=!Throttlefps;
4494 zc_set_config(cfg_sect,"throttlefps", (int32_t)Throttlefps);
4495 logic_counter=0;
4496 }
4497 }
4498
4499 // if(zc_readkey(KEY_F1)) Vsync=!Vsync;
4500 /*
4501 if(zc_readkey(KEY_F1)) set_bit(QHeader.rules4,qr4_NEWENEMYTILES,
4502 1-((get_bit(QHeader.rules4,qr4_NEWENEMYTILES))));
4503 */
4504
4505
1/2
✓ Branch 0 taken 6510614 times.
✗ Branch 1 not taken.
6510614 if(zc_read_system_key(KEY_F2))
4506 {
4507 ShowFPS=!ShowFPS;
4508 zc_set_config(cfg_sect,"showfps",(int32_t)ShowFPS);
4509 }
4510
4511
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6510614 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6510614 if(zc_read_system_key(KEY_F3) && Playing) Paused=!Paused;
4512
4513
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6510614 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6510614 if(zc_read_system_key(KEY_F4) && Playing)
4514 {
4515 Paused=true;
4516 Advance=true;
4517 }
4518
4519
1/2
✓ Branch 0 taken 6510614 times.
✗ Branch 1 not taken.
6510614 if(zc_read_system_key(KEY_F6)) onTryQuit();
4520
4521 #ifndef ALLEGRO_MACOSX
4522
1/2
✓ Branch 0 taken 6510614 times.
✗ Branch 1 not taken.
6510614 if(zc_read_system_key(KEY_F9)) f_Quit(qRESET);
4523
4524
1/2
✓ Branch 0 taken 6510614 times.
✗ Branch 1 not taken.
6510614 if(zc_read_system_key(KEY_F10)) f_Quit(qEXIT);
4525 #else
4526 if(zc_read_system_key(KEY_F7)) f_Quit(qRESET);
4527
4528 if(zc_read_system_key(KEY_F8)) f_Quit(qEXIT);
4529 #endif
4530
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 6510614 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
6510614 if(zc_read_system_key(KEY_F5)&&(Playing && currscr<128 && DMaps[currdmap].flags&dmfVIEWMAP)) onSaveMapPic();
4531
4532
1/2
✓ Branch 0 taken 6510614 times.
✗ Branch 1 not taken.
6510614 if (zc_read_system_key(KEY_F12))
4533 {
4534 onSnapshot();
4535 }
4536
4537
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6510614 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6510614 if(debug_enabled && zc_read_system_key(KEY_TAB))
4538 set_debug(!get_debug());
4539
4540
1/2
✓ Branch 0 taken 6510614 times.
✗ Branch 1 not taken.
6510614 if(CheatModifierKeys())
4541 {
4542 for(Cheat c = (Cheat)1; c < Cheat::Last; c = (Cheat)(c+1))
4543 {
4544 if(!bindable_cheat(c))
4545 continue;
4546 if(get_debug() || cheat >= cheat_lvl(c))
4547 {
4548 if(checkcheat(c))
4549 cheats_hit_bind(c);
4550 }
4551 }
4552 }
4553
4554
1/2
✓ Branch 0 taken 6510614 times.
✗ Branch 1 not taken.
6510614 if(volkeys)
4555 {
4556 if(zc_read_system_key(KEY_PGUP)) master_volume(-1,midi_volume+8);
4557
4558 if(zc_read_system_key(KEY_PGDN)) master_volume(-1,midi_volume==255?248:midi_volume-8);
4559
4560 if(zc_read_system_key(KEY_HOME)) master_volume(digi_volume+8,-1);
4561
4562 if(zc_read_system_key(KEY_END)) master_volume(digi_volume==255?248:digi_volume-8,-1);
4563 }
4564
4565
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 6510614 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
6510614 if(!get_debug() || !SystemKeys || replay_is_replaying())
4566 6510614 goto bottom;
4567
4568 if(zc_readkey(KEY_D))
4569 {
4570 details = !details;
4571 rectfill(screen,0,0,319,7,BLACK);
4572 rectfill(screen,0,8,31,239,BLACK);
4573 rectfill(screen,288,8,319,239,BLACK);
4574 rectfill(screen,32,232,287,239,BLACK);
4575 }
4576
4577 if(zc_readkey(KEY_P)) Paused=!Paused;
4578
4579 //if(zc_readkey(KEY_P)) centerHero();
4580 if(zc_readkey(KEY_A))
4581 {
4582 Paused=true;
4583 Advance=true;
4584 }
4585
4586 if(zc_readkey(KEY_G)) db=(db==999)?0:999;
4587 #ifndef ALLEGRO_MACOSX
4588 if(zc_readkey(KEY_F8)) Showpal=!Showpal;
4589
4590 if(zc_readkey(KEY_F7))
4591 {
4592 Matrix(ss_speed, ss_density, 0);
4593 game_pal();
4594 }
4595 #else
4596 // The reason these are different on Mac in the first place is that
4597 // the OS doesn't let us use F9 and F10...
4598 if(zc_readkey(KEY_F10)) Showpal=!Showpal;
4599
4600 if(zc_readkey(KEY_F9))
4601 {
4602 Matrix(ss_speed, ss_density, 0);
4603 game_pal();
4604 }
4605 #endif
4606 if(zc_readkey(KEY_PLUS_PAD) || zc_readkey(KEY_EQUALS))
4607 {
4608 //change containers
4609 if(zc_getkey(KEY_ZC_LCONTROL) || zc_getkey(KEY_ZC_RCONTROL))
4610 {
4611 //magic containers
4612 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4613 {
4614 game->set_maxmagic(zc_min(game->get_maxmagic()+game->get_mp_per_block(),game->get_mp_per_block()*8));
4615 }
4616 else
4617 {
4618 game->set_maxlife(zc_min(game->get_maxlife()+game->get_hp_per_heart(),game->get_hp_per_heart()*24));
4619 }
4620 }
4621 else
4622 {
4623 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4624 {
4625 game->set_magic(zc_min(game->get_magic()+1,game->get_maxmagic()));
4626 }
4627 else
4628 {
4629 game->set_life(zc_min(game->get_life()+1,game->get_maxlife()));
4630 }
4631 }
4632 }
4633
4634 if(zc_readkey(KEY_MINUS_PAD) || zc_readkey(KEY_MINUS))
4635 {
4636 //change containers
4637 if(zc_getkey(KEY_ZC_LCONTROL) || zc_getkey(KEY_ZC_RCONTROL))
4638 {
4639 //magic containers
4640 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4641 {
4642 game->set_maxmagic(zc_max(game->get_maxmagic()-game->get_mp_per_block(),0));
4643 game->set_magic(zc_min(game->get_maxmagic(), game->get_magic()));
4644 //heart containers
4645 }
4646 else
4647 {
4648 game->set_maxlife(zc_max(game->get_maxlife()-game->get_hp_per_heart(),game->get_hp_per_heart()));
4649 game->set_life(zc_min(game->get_maxlife(), game->get_life()));
4650 }
4651 }
4652 else
4653 {
4654 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4655 {
4656 game->set_magic(zc_max(game->get_magic()-1,0));
4657 }
4658 else
4659 {
4660 game->set_life(zc_max(game->get_life()-1,0));
4661 }
4662 }
4663 }
4664
4665 if(zc_readkey(KEY_COMMA)) jukebox(currmidi-1);
4666
4667 if(zc_readkey(KEY_STOP)) jukebox(currmidi+1);
4668
4669 verifyBothWeapons();
4670
4671 bottom:
4672
4673
1/2
✓ Branch 0 taken 6510614 times.
✗ Branch 1 not taken.
6510614 if(input_idle(true) > after_time())
4674 {
4675 Matrix(ss_speed, ss_density, 0);
4676 game_pal();
4677 }
4678 6510614 }
4679
4680 330136 void checkQuitKeys()
4681 {
4682 #ifndef ALLEGRO_MACOSX
4683
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 330136 times.
330136 if(key[KEY_F9]) f_Quit(qRESET);
4684
4685
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 330136 times.
330136 if(key[KEY_F10]) f_Quit(qEXIT);
4686 #else
4687 if(key[KEY_F7]) f_Quit(qRESET);
4688
4689 if(key[KEY_F8]) f_Quit(qEXIT);
4690 #endif
4691 330136 }
4692
4693 6510614 bool CheatModifierKeys()
4694 {
4695 // Cheats are replayed via the X cheat step, no need to check for keyboard input
4696 // to trigger cheats.
4697
1/2
✓ Branch 0 taken 6510614 times.
✗ Branch 1 not taken.
6510614 if (replay_is_replaying())
4698 6510614 return false;
4699
4700 if ( ( cheat_modifier_keys[0] > 0 && key[cheat_modifier_keys[0]] ) ||
4701 ( cheat_modifier_keys[1] > 0 && key[cheat_modifier_keys[1]] ) ||
4702 (cheat_modifier_keys[0] <= 0 && cheat_modifier_keys[1] <= 0))
4703 {
4704 if ( ( cheat_modifier_keys[2] <= 0 || key[cheat_modifier_keys[2]] ) ||
4705 ( cheat_modifier_keys[3] > 0 && key[cheat_modifier_keys[3]] ) ||
4706 (cheat_modifier_keys[2] <= 0 && cheat_modifier_keys[3] <= 0))
4707 {
4708 return true;
4709 }
4710 }
4711 return false;
4712 6510614 }
4713
4714 //99:05:54, for some reason?
4715 #define OLDMAXTIME 21405240
4716 //9000:00:00, the highest even-thousand hour fitting within 32b signed. This is 375 *DAYS*.
4717 #define MAXTIME 1944000000
4718
4719 6510665 void advanceframe(bool allowwavy, bool sfxcleanup, bool allowF6Script)
4720 {
4721
2/2
✓ Branch 0 taken 6242564 times.
✓ Branch 1 taken 268101 times.
6510665 if(zcmusic!=NULL)
4722 {
4723 268101 zcmusic_poll();
4724 268101 }
4725
4726 6510665 updatescr(allowwavy);
4727
4728
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 6510665 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 6510665 times.
6510665 while(Paused && !Advance && !Quit)
4729 {
4730 // have to call this, otherwise we'll get an infinite loop
4731 syskeys();
4732 if(allowF6Script)
4733 {
4734 FFCore.runF6Engine();
4735 }
4736 throttleFPS();
4737
4738 #ifdef _WIN32
4739
4740 if(use_dwm_flush)
4741 {
4742 do_DwmFlush();
4743 }
4744
4745 #endif
4746
4747 // to keep music playing
4748 if(zcmusic!=NULL)
4749 {
4750 zcmusic_poll();
4751 }
4752
4753 update_hw_screen();
4754 }
4755
4756
2/2
✓ Branch 0 taken 6510624 times.
✓ Branch 1 taken 41 times.
6510665 if(Quit)
4757 41 return;
4758
4759
3/4
✓ Branch 0 taken 6428635 times.
✓ Branch 1 taken 81989 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6428635 times.
6510624 if(Playing && game->get_time()<unsigned(get_bit(quest_rules,qr_GREATER_MAX_TIME) ? MAXTIME : OLDMAXTIME))
4760 6428635 game->change_time(1);
4761
4762 6510624 Advance=false;
4763
4764
2/4
✓ Branch 0 taken 6510624 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6510624 times.
6510624 if (!replay_is_active() || replay_get_version() >= 11)
4765 for (int i = 0; i < ZC_CONTROL_STATES; i++)
4766 down_control_states[i] = raw_control_state[i];
4767
4768
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 6510622 times.
6510624 if (replay_is_active())
4769 {
4770
2/2
✓ Branch 0 taken 1270461 times.
✓ Branch 1 taken 5240161 times.
6510622 if (replay_get_version() >= 3)
4771 5240161 replay_poll();
4772
4773
5/6
✓ Branch 0 taken 6510614 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3089962 times.
✓ Branch 3 taken 3420652 times.
✓ Branch 4 taken 100535 times.
✓ Branch 5 taken 2989427 times.
6510622 if (replay_get_version() >= 11 || (replay_get_version() >= 6 && replay_get_version() < 8))
4774 100535 replay_peek_input();
4775 6510614 }
4776
4777 6510624 load_control_called_this_frame = false;
4778
4779 6510624 poll_keyboard();
4780 6510624 update_keys();
4781
4782 6510624 ++frame;
4783
4784
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 6510614 times.
6510624 if (replay_is_replaying())
4785 6510614 replay_do_cheats();
4786 6510624 syskeys();
4787
4788 // The mouse variables can change from the mouse thread at anytime during a frame,
4789 // so save the result at the start so that replaying is consistent.
4790 6510624 script_mouse_x = gui_mouse_x();
4791 6510624 script_mouse_y = gui_mouse_y();
4792 6510624 script_mouse_z = mouse_z;
4793 6510624 script_mouse_b = mouse_b;
4794
4795 // Cheats used via the System menu (called by syskeys) will call cheats_enqueue. syskeys
4796 // is called just above, and in the paused loop above, so the queue-and-defer-slightly
4797 // approach here means it doesn't matter which call adds the cheat.
4798 6510624 cheats_execute_queued();
4799
4800
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 6510614 times.
6510624 if (replay_is_replaying())
4801 6510614 replay_peek_quit();
4802
2/2
✓ Branch 0 taken 6510610 times.
✓ Branch 1 taken 14 times.
6510624 if (GameFlags & GAMEFLAG_TRYQUIT)
4803 14 replay_step_quit(0);
4804
2/2
✓ Branch 0 taken 1835 times.
✓ Branch 1 taken 6508789 times.
6510624 if(allowF6Script)
4805 {
4806 6508789 FFCore.runF6Engine();
4807 6508789 }
4808
2/2
✓ Branch 0 taken 6510449 times.
✓ Branch 1 taken 175 times.
6510624 if (Quit)
4809 175 replay_step_quit(Quit);
4810 // Someday... maybe install a Turbo button here?
4811 6510624 throttleFPS();
4812
4813 #ifdef _WIN32
4814
4815 if(use_dwm_flush)
4816 {
4817 do_DwmFlush();
4818 }
4819
4820 #endif
4821
4822 //textprintf_ex(screen,font,0,72,254,BLACK,"%d %d", lastentrance, lastentrance_dmap);
4823
2/2
✓ Branch 0 taken 29901 times.
✓ Branch 1 taken 6480723 times.
6510624 if(sfxcleanup)
4824 6480723 sfx_cleanup();
4825 6510665 }
4826
4827 59 void zapout()
4828 {
4829 59 set_clip_rect(scrollbuf, 0, 0, scrollbuf->w, scrollbuf->h);
4830 59 blit(framebuf,scrollbuf,0,0,256,0,256,224);
4831
4832 59 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4833 59 script_drawing_commands.Clear();
4834
4835 // zap out
4836
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 1416 times.
1475 for(int32_t i=1; i<=24; i++)
4837 {
4838 1416 draw_fuzzy(i);
4839 1416 advanceframe(true);
4840
4841
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1416 times.
1416 if(Quit)
4842 {
4843 break;
4844 }
4845 1416 }
4846 59 }
4847
4848 59 void zapin()
4849 {
4850 59 FFCore.warpScriptCheck();
4851 59 draw_screen(tmpscr);
4852 59 set_clip_rect(scrollbuf, 0, 0, scrollbuf->w, scrollbuf->h);
4853 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
4854 59 blit(framebuf,scrollbuf,0,0,256,0,256,224);
4855
4856 // zap out
4857 59 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4858
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 1416 times.
1475 for(int32_t i=24; i>=1; i--)
4859 {
4860 1416 draw_fuzzy(i);
4861 1416 advanceframe(true);
4862
4863
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1416 times.
1416 if(Quit)
4864 {
4865 break;
4866 }
4867 1416 }
4868 59 }
4869
4870
4871 23 void wavyout(bool showhero)
4872 {
4873 23 draw_screen(tmpscr, showhero);
4874 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
4875
4876 23 BITMAP *wavebuf = create_bitmap_ex(8,288,224);
4877 23 clear_to_color(wavebuf,0);
4878 23 blit(framebuf,wavebuf,0,0,16,0,256,224);
4879
4880 static PALETTE wavepal;
4881
4882 int32_t ofs;
4883 23 int32_t amplitude=8;
4884
4885 23 int32_t wavelength=4;
4886 23 double palpos=0, palstep=4, palstop=126;
4887
4888 23 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4889
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 966 times.
989 for(int32_t i=0; i<168; i+=wavelength)
4890 {
4891
2/2
✓ Branch 0 taken 247296 times.
✓ Branch 1 taken 966 times.
248262 for(int32_t l=0; l<256; l++)
4892 {
4893 247296 wavepal[l].r=vbound(int32_t(RAMpal[l].r+((palpos/palstop)*(63-RAMpal[l].r))),0,63);
4894 247296 wavepal[l].g=vbound(int32_t(RAMpal[l].g+((palpos/palstop)*(63-RAMpal[l].g))),0,63);
4895 247296 wavepal[l].b=vbound(int32_t(RAMpal[l].b+((palpos/palstop)*(63-RAMpal[l].b))),0,63);
4896 247296 }
4897
4898 966 palpos+=palstep;
4899
4900
1/2
✓ Branch 0 taken 966 times.
✗ Branch 1 not taken.
966 if(palpos>=0)
4901 {
4902 966 hw_palette = &wavepal;
4903 966 update_hw_pal = true;
4904 966 }
4905 else
4906 {
4907 hw_palette = &RAMpal;
4908 update_hw_pal = true;
4909 }
4910
4911
2/2
✓ Branch 0 taken 162288 times.
✓ Branch 1 taken 966 times.
163254 for(int32_t j=0; j+playing_field_offset<224; j++)
4912 {
4913
2/2
✓ Branch 0 taken 41545728 times.
✓ Branch 1 taken 162288 times.
41708016 for(int32_t k=0; k<256; k++)
4914 {
4915 41545728 ofs=0;
4916
4917
4/4
✓ Branch 0 taken 20278272 times.
✓ Branch 1 taken 21267456 times.
✓ Branch 2 taken 10139136 times.
✓ Branch 3 taken 10139136 times.
41545728 if((j<i)&&(j&1))
4918 {
4919 10139136 ofs=int32_t(zc::math::Sin((double(i+j)*2*PI/168.0))*amplitude);
4920 10139136 }
4921
4922 41545728 framebuf->line[j+playing_field_offset][k]=wavebuf->line[j+playing_field_offset][k+ofs+16];
4923 41545728 }
4924 162288 }
4925
4926 966 advanceframe(true);
4927
4928 // animate_combos();
4929
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 966 times.
966 if(Quit)
4930 break;
4931 966 }
4932
4933 23 destroy_bitmap(wavebuf);
4934 23 }
4935
4936 23 void wavyin()
4937 {
4938 23 draw_screen(tmpscr);
4939 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
4940
4941 23 BITMAP *wavebuf = create_bitmap_ex(8,288,224);
4942 23 clear_to_color(wavebuf,0);
4943 23 blit(framebuf,wavebuf,0,0,16,0,256,224);
4944
4945 static PALETTE wavepal;
4946
4947 //Breaks dark rooms.
4948 //In any case I don't think we need this, since palette is already loaded in doWarp() (famous last words...) -DD
4949 /*
4950 loadfullpal();
4951 loadlvlpal(DMaps[currdmap].color);
4952 ringcolor(false);
4953 */
4954 23 refreshpal=false;
4955 int32_t ofs;
4956 23 int32_t amplitude=8;
4957 23 int32_t wavelength=4;
4958 23 double palpos=168, palstep=4, palstop=126;
4959
4960 23 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4961
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 966 times.
989 for(int32_t i=0; i<168; i+=wavelength)
4962 {
4963
2/2
✓ Branch 0 taken 247296 times.
✓ Branch 1 taken 966 times.
248262 for(int32_t l=0; l<256; l++)
4964 {
4965 247296 wavepal[l].r=vbound(int32_t(RAMpal[l].r+((palpos/palstop)*(63-RAMpal[l].r))),0,63);
4966 247296 wavepal[l].g=vbound(int32_t(RAMpal[l].g+((palpos/palstop)*(63-RAMpal[l].g))),0,63);
4967 247296 wavepal[l].b=vbound(int32_t(RAMpal[l].b+((palpos/palstop)*(63-RAMpal[l].b))),0,63);
4968 247296 }
4969
4970 966 palpos-=palstep;
4971
4972
1/2
✓ Branch 0 taken 966 times.
✗ Branch 1 not taken.
966 if(palpos>=0)
4973 {
4974 966 hw_palette = &wavepal;
4975 966 update_hw_pal = true;
4976 966 }
4977 else
4978 {
4979 hw_palette = &RAMpal;
4980 update_hw_pal = true;
4981 }
4982
4983
2/2
✓ Branch 0 taken 162288 times.
✓ Branch 1 taken 966 times.
163254 for(int32_t j=0; j+playing_field_offset<224; j++)
4984 {
4985
2/2
✓ Branch 0 taken 41545728 times.
✓ Branch 1 taken 162288 times.
41708016 for(int32_t k=0; k<256; k++)
4986 {
4987 41545728 ofs=0;
4988
4989
4/4
✓ Branch 0 taken 21020160 times.
✓ Branch 1 taken 20525568 times.
✓ Branch 2 taken 10633728 times.
✓ Branch 3 taken 10386432 times.
41545728 if((j<(167-i))&&(j&1))
4990 {
4991 10386432 ofs=int32_t(zc::math::Sin((double(i+j)*2*PI/168.0))*amplitude);
4992 10386432 }
4993
4994 41545728 framebuf->line[j+playing_field_offset][k]=wavebuf->line[j+playing_field_offset][k+ofs+16];
4995 41545728 }
4996 162288 }
4997
4998 966 advanceframe(true);
4999 // animate_combos();
5000
5001
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 966 times.
966 if(Quit)
5002 break;
5003 966 }
5004
5005 23 destroy_bitmap(wavebuf);
5006 23 }
5007
5008 1619 void blackscr(int32_t fcnt,bool showsubscr)
5009 {
5010 1619 reset_pal_cycling();
5011 1619 script_drawing_commands.Clear();
5012
5013 1619 FFCore.warpScriptCheck();
5014 1619 bool showtime = game->should_show_time();
5015
2/2
✓ Branch 0 taken 1619 times.
✓ Branch 1 taken 48500 times.
50119 while(fcnt>0)
5016 {
5017 48500 clear_bitmap(framebuf);
5018
5019
2/2
✓ Branch 0 taken 13500 times.
✓ Branch 1 taken 35000 times.
48500 if(showsubscr)
5020 {
5021 35000 put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,showtime,sspUP);
5022
3/4
✓ Branch 0 taken 35000 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 750 times.
✓ Branch 3 taken 34250 times.
35000 if(get_bit(quest_rules, qr_SCRIPTDRAWSINWARPS) || (get_bit(quest_rules, qr_PASSIVE_SUBSCRIPT_RUNS_WHEN_GAME_IS_FROZEN)))
5023 {
5024 750 do_script_draws(framebuf, tmpscr, 0, playing_field_offset);
5025 750 }
5026 35000 }
5027
5028 48500 advanceframe(true);
5029
5030
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48500 times.
48500 if(Quit)
5031 break;
5032
5033 48500 --fcnt;
5034 }
5035 1619 }
5036
5037 563 void openscreen(int32_t shape)
5038 {
5039 563 reset_pal_cycling();
5040 563 black_opening_count=0;
5041
5042
3/4
✓ Branch 0 taken 98 times.
✓ Branch 1 taken 465 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 98 times.
563 if(COOLSCROLL || shape>-1)
5043 {
5044 465 open_black_opening(HeroX()+8, (HeroY()-HeroZ()-HeroFakeZ())+8+playing_field_offset, true, shape);
5045 465 return;
5046 }
5047 else
5048 {
5049 98 Hero.setDontDraw(true);
5050 98 show_subscreen_dmap_dots=false;
5051 98 show_subscreen_numbers=false;
5052 // show_subscreen_items=false;
5053 98 show_subscreen_life=false;
5054 }
5055
5056 98 int32_t x=128;
5057
5058 98 FFCore.warpScriptCheck();
5059
2/2
✓ Branch 0 taken 98 times.
✓ Branch 1 taken 7840 times.
7938 for(int32_t i=0; i<80; i++)
5060 {
5061 7840 draw_screen(tmpscr);
5062 //? draw_screen already draws the subscreen -DD
5063 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
5064 7840 x=128-(((i*128/80)/8)*8);
5065
5066
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7840 times.
7840 if(x>0)
5067 {
5068 7840 rectfill(framebuf,0,playing_field_offset,x,167+playing_field_offset,0);
5069 7840 rectfill(framebuf,256-x,playing_field_offset,255,167+playing_field_offset,0);
5070 7840 }
5071
5072 7840 advanceframe(true);
5073
5074
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7840 times.
7840 if(Quit)
5075 {
5076 break;
5077 }
5078 7840 }
5079
5080 98 Hero.setDontDraw(false);
5081 98 show_subscreen_items=true;
5082 98 show_subscreen_dmap_dots=true;
5083 563 }
5084
5085 void closescreen(int32_t shape)
5086 {
5087 reset_pal_cycling();
5088 black_opening_count=0;
5089
5090 if(COOLSCROLL || shape>-1)
5091 {
5092 close_black_opening(HeroX()+8, (HeroY()-HeroZ()-HeroFakeZ())+8+playing_field_offset, true, shape);
5093 return;
5094 }
5095 else
5096 {
5097 Hero.setDontDraw(true);
5098 show_subscreen_dmap_dots=false;
5099 show_subscreen_numbers=false;
5100 // show_subscreen_items=false;
5101 show_subscreen_life=false;
5102 }
5103
5104 int32_t x=128;
5105
5106 FFCore.warpScriptCheck();
5107 for(int32_t i=79; i>=0; --i)
5108 {
5109 draw_screen(tmpscr);
5110 //? draw_screen already draws the subscreen -DD
5111 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
5112 x=128-(((i*128/80)/8)*8);
5113
5114 if(x>0)
5115 {
5116 rectfill(framebuf,0,playing_field_offset,x,167+playing_field_offset,0);
5117 rectfill(framebuf,256-x,playing_field_offset,255,167+playing_field_offset,0);
5118 }
5119
5120 advanceframe(true);
5121
5122 if(Quit)
5123 {
5124 break;
5125 }
5126 }
5127
5128 Hero.setDontDraw(false);
5129 show_subscreen_items=true;
5130 show_subscreen_dmap_dots=true;
5131 }
5132
5133 122 int32_t TriforceCount()
5134 {
5135 122 int32_t c=0;
5136
5137
2/2
✓ Branch 0 taken 976 times.
✓ Branch 1 taken 122 times.
1098 for(int32_t i=1; i<=8; i++)
5138
2/2
✓ Branch 0 taken 326 times.
✓ Branch 1 taken 650 times.
1626 if(game->lvlitems[i]&liTRIFORCE)
5139 650 ++c;
5140
5141 122 return c;
5142 }
5143
5144 int32_t onCustomGame()
5145 {
5146 int32_t file = getsaveslot();
5147
5148 if(file < 0)
5149 return D_O_K;
5150
5151 bool ret = (custom_game(file)!=0);
5152 return ret ? D_CLOSE : D_O_K;
5153 }
5154
5155 int32_t onContinue()
5156 {
5157 return D_CLOSE;
5158 }
5159
5160 int32_t onEsc() // Unused?? -L
5161 {
5162 return zc_getrawkey(KEY_ESC, true)?D_CLOSE:D_O_K;
5163 }
5164
5165 int32_t onVsync()
5166 {
5167 Throttlefps = !Throttlefps;
5168 zc_set_config(cfg_sect,"throttlefps", (int32_t)Throttlefps);
5169 return D_O_K;
5170 }
5171
5172 int32_t onWinPosSave()
5173 {
5174 SaveWinPos = !SaveWinPos;
5175 zc_set_config(cfg_sect,"save_window_position",(int32_t)SaveWinPos);
5176 return D_O_K;
5177 }
5178
5179 int32_t onClickToFreeze()
5180 {
5181 ClickToFreeze = !ClickToFreeze;
5182 zc_set_config(cfg_sect,"clicktofreeze", (int32_t)ClickToFreeze);
5183 return D_O_K;
5184 }
5185
5186 int32_t OnSaveZCConfig()
5187 {
5188 if(jwin_alert3(
5189 "Save Configuration",
5190 "Are you sure that you wish to save your present configuration settings?",
5191 "This will overwrite your prior settings!",
5192 NULL,
5193 "&Yes",
5194 "&No",
5195 NULL,
5196 'y',
5197 'n',
5198 0,
5199 lfont) == 1)
5200 {
5201 save_game_configs();
5202 return D_O_K;
5203 }
5204 else return D_O_K;
5205 }
5206
5207 int32_t OnnClearQuestDir()
5208 {
5209 if(jwin_alert3(
5210 "Clear Current Directory Cache",
5211 "Are you sure that you wish to clear the current cached directory?",
5212 "This will default the current directory to the ROOT for this instance of ZC Player!",
5213 NULL,
5214 "&Yes",
5215 "&No",
5216 NULL,
5217 'y',
5218 'n',
5219 0,
5220 lfont) == 1)
5221 {
5222 zc_set_config("zeldadx","win_qst_dir","");
5223 flush_config_file();
5224 strcpy(qstdir,"");
5225 #ifdef __EMSCRIPTEN__
5226 em_sync_fs();
5227 #endif
5228 return D_O_K;
5229 }
5230 else return D_O_K;
5231 }
5232
5233
5234 int32_t onConsoleZASM()
5235 {
5236 if ( !zasm_debugger )
5237 {
5238 AlertDialog("WARNING: ZASM Debugger",
5239 "Enabling this will open the ZASM Debugger Console"
5240 "\nThis will likely grind ZC to a halt with lag."
5241 "\nTo make any use of this, it is suggested that you read"
5242 "\nthe documentation for 'void Breakpoint(char[] string);'"
5243 " in 'ZScript_Additions.txt'"
5244 "\nThis is not recommended for normal users,"
5245 " and is only intended for ZC developers,"
5246 "\nor quest developers coding directly in ZASM"
5247 "\nAre you sure that you wish to open the ZASM Debugger?",
5248 [&](bool ret,bool)
5249 {
5250 if(ret)
5251 {
5252 FFCore.ZASMPrint(true);
5253 }
5254 }).show();
5255 return D_O_K;
5256 }
5257 else
5258 {
5259 FFCore.ZASMPrint(false);
5260 return D_O_K;
5261 }
5262 }
5263
5264
5265 int32_t onConsoleZScript()
5266 {
5267 if ( !zscript_debugger )
5268 {
5269 AlertDialog("ZScript Debugger",
5270 "Enabling this will open the ZScript Debugger Console"
5271 "\nThis will display any messages logged by scripts,"
5272 " including script errors."
5273 "\nAre you sure that you wish to open the ZScript Debugger?",
5274 [&](bool ret,bool)
5275 {
5276 if(ret)
5277 {
5278 FFCore.ZScriptConsole(true);
5279 }
5280 }).show();
5281 return D_O_K;
5282 }
5283 else
5284 {
5285 FFCore.ZScriptConsole(false);
5286 return D_O_K;
5287 }
5288 }
5289
5290 int32_t onClrConsoleOnLoad()
5291 {
5292 clearConsoleOnLoad = !clearConsoleOnLoad;
5293 zc_set_config("CONSOLE","clear_console_on_load",clearConsoleOnLoad?1:0);
5294 return D_O_K;
5295 }
5296
5297
5298 int32_t onFrameSkip()
5299 {
5300 FrameSkip = !FrameSkip;
5301 return D_O_K;
5302 }
5303
5304 int32_t onSaveDragResize()
5305 {
5306 SaveDragResize = !SaveDragResize;
5307 zc_set_config(cfg_sect,"save_drag_resize",(int32_t)SaveDragResize);
5308 return D_O_K;
5309 }
5310
5311 int32_t onDragAspect()
5312 {
5313 DragAspect = !DragAspect;
5314 zc_set_config(cfg_sect,"drag_aspect",(int32_t)DragAspect);
5315 return D_O_K;
5316 }
5317
5318 int32_t onTransLayers()
5319 {
5320 TransLayers = !TransLayers;
5321 zc_set_config(cfg_sect,"translayers",(int32_t)TransLayers);
5322 return D_O_K;
5323 }
5324
5325 int32_t onNESquit()
5326 {
5327 NESquit = !NESquit;
5328 zc_set_config(cfg_sect,"fastquit",(int32_t)NESquit);
5329 return D_O_K;
5330 }
5331
5332 int32_t onVolKeys()
5333 {
5334 volkeys = !volkeys;
5335 zc_set_config(sfx_sect,"volkeys",(int32_t)volkeys);
5336 return D_O_K;
5337 }
5338
5339 int32_t onShowFPS()
5340 {
5341 ShowFPS = !ShowFPS;
5342 zc_set_config(cfg_sect,"showfps",(int32_t)ShowFPS);
5343 return D_O_K;
5344 }
5345
5346 768252452 bool is_Fkey(int32_t k)
5347 {
5348
2/2
✓ Branch 0 taken 78127368 times.
✓ Branch 1 taken 690125084 times.
768252452 switch(k)
5349 {
5350 case KEY_F1:
5351 case KEY_F2:
5352 case KEY_F3:
5353 case KEY_F4:
5354 case KEY_F5:
5355 case KEY_F6:
5356 case KEY_F7:
5357 case KEY_F8:
5358 case KEY_F9:
5359 case KEY_F10:
5360 case KEY_F11:
5361 case KEY_F12:
5362 78127368 return true;
5363 }
5364
5365 690125084 return false;
5366 768252452 }
5367
5368 void kb_getkey(DIALOG *d);
5369
5370 //Used by all keyboard key settings dialogues.
5371 void kb_clearjoystick(DIALOG *d)
5372 {
5373 d->flags|=D_SELECTED;
5374
5375 scare_mouse();
5376 jwin_button_proc(MSG_DRAW,d,0);
5377 unscare_mouse();
5378 popup_zqdialog_start();
5379 scare_mouse();
5380 jwin_draw_win(screen, (screen->w-160)/2, (screen->h-48)/2, 168, 48, FR_WIN);
5381 // text_mode(vc(11));
5382 textout_centre_ex(screen, font, "Press any key to clear", screen->w/2, screen->h/2 - 8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5383 textout_centre_ex(screen, font, "ESC to cancel", screen->w/2, screen->h/2, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5384 unscare_mouse();
5385
5386 update_hw_screen(true);
5387
5388 clear_keybuf();
5389 int32_t k = next_press_key();
5390 clear_keybuf();
5391
5392 //shnarf
5393 //47=f1
5394 //59=esc
5395 // if(k>0 && k<123 && !((k>46)&&(k<60)))
5396 // *((int32_t*)d->dp3) = k;
5397 if ( k != 59 ) *((int32_t*)d->dp3) = 0;
5398
5399
5400 d->flags&=~D_SELECTED;
5401 popup_zqdialog_end();
5402 }
5403
5404 //Clears key to 0.
5405 //Used by all keyboard key settings dialogues.
5406 void kb_clearkey(DIALOG *d);
5407
5408 int32_t d_j_clearbutton_proc(int32_t msg,DIALOG *d,int32_t c)
5409 {
5410 switch(msg)
5411 {
5412 case MSG_KEY:
5413 case MSG_CLICK:
5414
5415 kb_clearjoystick(d);
5416
5417 while(gui_mouse_b())
5418 {
5419 clear_keybuf();
5420 rest(1);
5421 }
5422
5423 return D_REDRAW;
5424 }
5425
5426 return jwin_button_proc(msg,d,c);
5427 }
5428
5429 int32_t d_kbutton_proc(int32_t msg,DIALOG *d,int32_t c);
5430 //Only used in keyboard settings dialogues to clear keys.
5431 int32_t d_k_clearbutton_proc(int32_t msg,DIALOG *d,int32_t c);
5432
5433 void j_getbtn(DIALOG *d)
5434 {
5435 d->flags|=D_SELECTED;
5436 scare_mouse();
5437 jwin_button_proc(MSG_DRAW,d,0);
5438 unscare_mouse();
5439 popup_zqdialog_start();
5440 scare_mouse();
5441 jwin_draw_win(screen, (screen->w-160)/2, (screen->h-48)/2, 160, 48, FR_WIN);
5442 // text_mode(vc(11));
5443 int32_t y = screen->h/2 - 12;
5444 textout_centre_ex(screen, font, "Press a button", screen->w/2, y, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5445 textout_centre_ex(screen, font, "ESC to cancel", screen->w/2, y+8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5446 textout_centre_ex(screen, font, "SPACE to disable", screen->w/2, y+16, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5447 unscare_mouse();
5448
5449 update_hw_screen(true);
5450
5451 int32_t b = next_press_btn();
5452
5453 if(b>=0)
5454 *((int32_t*)d->dp3) = b;
5455
5456 d->flags&=~D_SELECTED;
5457
5458 if (player)
5459 player->joy_on = TRUE;
5460 popup_zqdialog_end();
5461 }
5462
5463 int32_t d_jbutton_proc(int32_t msg,DIALOG *d,int32_t c)
5464 {
5465 switch(msg)
5466 {
5467 case MSG_KEY:
5468 case MSG_CLICK:
5469
5470 j_getbtn(d);
5471
5472 while(gui_mouse_b()) {
5473 rest(1);
5474 clear_keybuf();
5475 }
5476
5477 return D_REDRAW;
5478 }
5479
5480 return jwin_button_proc(msg,d,c);
5481 }
5482
5483 //shnarf
5484 extern const char *key_str[];
5485 std::string get_keystr(int key);
5486
5487 const char *pan_str[4] = { "MONO", " 1/2", " 3/4", "FULL" };
5488 //extern int32_t zcmusic_bufsz;
5489
5490 static char str_a[80],str_b[80],str_s[80],str_m[80],str_l[80],str_r[80],str_p[80],str_ex1[80],str_ex2[80],str_ex3[80],str_ex4[80],
5491 str_leftmod1[80],str_leftmod2[80],str_rightmod1[80],str_rightmod2[80], str_left[80], str_right[80], str_up[80], str_down[80];
5492
5493 int32_t d_stringloader(int32_t msg,DIALOG *d,int32_t c)
5494 {
5495 //these are here to bypass compiler warnings about unused arguments
5496 c=c;
5497
5498 if(msg==MSG_DRAW)
5499 {
5500 switch(d->w)
5501 {
5502 case 0:
5503 sprintf(str_a,"%03d\n%s",Akey,key_str[Akey]);
5504 sprintf(str_b,"%03d\n%s",Bkey,key_str[Bkey]);
5505 sprintf(str_s,"%03d\n%s",Skey,key_str[Skey]);
5506 sprintf(str_l,"%03d\n%s",Lkey,key_str[Lkey]);
5507 sprintf(str_r,"%03d\n%s",Rkey,key_str[Rkey]);
5508 sprintf(str_p,"%03d\n%s",Pkey,key_str[Pkey]);
5509 sprintf(str_ex1,"%03d\n%s",Exkey1,key_str[Exkey1]);
5510 sprintf(str_ex2,"%03d\n%s",Exkey2,key_str[Exkey2]);
5511 sprintf(str_ex3,"%03d\n%s",Exkey3,key_str[Exkey3]);
5512 sprintf(str_ex4,"%03d\n%s",Exkey4,key_str[Exkey4]);
5513 sprintf(str_up,"%03d\n%s",DUkey,key_str[DUkey]);
5514 sprintf(str_down,"%03d\n%s",DDkey,key_str[DDkey]);
5515 sprintf(str_left,"%03d\n%s",DLkey,key_str[DLkey]);
5516 sprintf(str_right,"%03d\n%s",DRkey,key_str[DRkey]);
5517 sprintf(str_leftmod1,"%03d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5518 sprintf(str_leftmod2,"%03d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5519 sprintf(str_rightmod1,"%03d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5520 sprintf(str_rightmod2,"%03d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5521 break;
5522
5523 case 1:
5524 sprintf(str_a,"%03d\n%s",Abtn,joybtn_name(Abtn));
5525 sprintf(str_b,"%03d\n%s",Bbtn,joybtn_name(Bbtn));
5526 sprintf(str_s,"%03d\n%s",Sbtn,joybtn_name(Sbtn));
5527 sprintf(str_l,"%03d\n%s",Lbtn,joybtn_name(Lbtn));
5528 sprintf(str_r,"%03d\n%s",Rbtn,joybtn_name(Rbtn));
5529 sprintf(str_m,"%03d\n%s",Mbtn,joybtn_name(Mbtn));
5530 sprintf(str_p,"%03d\n%s",Pbtn,joybtn_name(Pbtn));
5531 sprintf(str_ex1,"%03d\n%s",Exbtn1,joybtn_name(Exbtn1));
5532 sprintf(str_ex2,"%03d\n%s",Exbtn2,joybtn_name(Exbtn2));
5533 sprintf(str_ex3,"%03d\n%s",Exbtn3,joybtn_name(Exbtn3));
5534 sprintf(str_ex4,"%03d\n%s",Exbtn4,joybtn_name(Exbtn4));
5535 sprintf(str_up,"%03d\n%s",DUbtn,joybtn_name(DUbtn));
5536 sprintf(str_down,"%03d\n%s",DDbtn,joybtn_name(DDbtn));
5537 sprintf(str_left,"%03d\n%s",DLbtn,joybtn_name(DLbtn));
5538 sprintf(str_right,"%03d\n%s",DRbtn,joybtn_name(DRbtn));
5539 sprintf(str_leftmod1,"%03d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5540 sprintf(str_leftmod2,"%03d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5541 sprintf(str_rightmod1,"%03d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5542 sprintf(str_rightmod2,"%03d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5543 break;
5544
5545 case 2:
5546 sprintf(str_a," %3d",midi_volume);
5547 sprintf(str_b," %3d",digi_volume);
5548 sprintf(str_l," %3d",emusic_volume);
5549 sprintf(str_m," %3dKB",zcmusic_bufsz);
5550 sprintf(str_r," %3d",sfx_volume);
5551 strcpy(str_s,pan_str[pan_style]);
5552 sprintf(str_leftmod1,"%3d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5553 sprintf(str_leftmod2,"%3d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5554 sprintf(str_rightmod1,"%3d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5555 sprintf(str_rightmod2,"%3d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5556 break;
5557 }
5558 }
5559
5560 return D_O_K;
5561 }
5562
5563 int32_t set_vol(void *dp3, int32_t d2)
5564 {
5565 switch(((int32_t*)dp3)[0])
5566 {
5567 case 0:
5568 midi_volume = zc_min(d2<<3,255);
5569 break;
5570
5571 case 1:
5572 digi_volume = zc_min(d2<<3,255);
5573 break;
5574
5575 case 2:
5576 emusic_volume = zc_min(d2<<3,255);
5577 break;
5578
5579 case 3:
5580 sfx_volume = zc_min(d2<<3,255);
5581 break;
5582 }
5583
5584 scare_mouse();
5585 // text_mode(vc(11));
5586 textprintf_right_ex(screen,lfont_l, ((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX],"%3d",zc_min(d2<<3,255));
5587 unscare_mouse();
5588 return D_O_K;
5589 }
5590
5591 int32_t set_pan(void *dp3, int32_t d2)
5592 {
5593 pan_style = vbound(d2,0,3);
5594 scare_mouse();
5595 // text_mode(vc(11));
5596 textout_right_ex(screen,lfont_l, pan_str[pan_style],((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5597 unscare_mouse();
5598 return D_O_K;
5599 }
5600
5601 int32_t set_buf(void *dp3, int32_t d2)
5602 {
5603 scare_mouse();
5604 // text_mode(vc(11));
5605 zcmusic_bufsz = d2 + 1;
5606 textprintf_right_ex(screen,lfont_l, ((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX],"%3dKB",zcmusic_bufsz);
5607 unscare_mouse();
5608 return D_O_K;
5609 }
5610
5611 static int32_t gamepad_btn_list[] =
5612 {
5613 6,
5614 7,8,9,10,11,12,13,14,15,16,17,
5615 18,19,20,21,22,23,24,25,26,27,28,
5616 29,30,31,32,33,34,35,36,37,38,39,
5617 -1
5618 };
5619
5620 static int32_t gamepad_dirs_list[] =
5621 {
5622 40,41,42,43,
5623 44,45,46,47,
5624 48,49,50,51,
5625 52,53,54,55,
5626 56,
5627 -1
5628 };
5629
5630 static TABPANEL gamepad_tabs[] =
5631 {
5632 // (text)
5633 { (char *)"Buttons", D_SELECTED, gamepad_btn_list, 0, NULL },
5634 { (char *)"Directions", 0, gamepad_dirs_list, 0, NULL },
5635 { NULL, 0, NULL, 0, NULL }
5636 };
5637
5638 static DIALOG gamepad_dlg[] =
5639 {
5640 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5641 { jwin_win_proc, 8, 24, 304, 256, 0, 0, 0, D_EXIT, 0, 0, (void *) "Gamepad Controls", NULL, NULL },
5642 { jwin_tab_proc, 8+4, 24+23,304-8,256-52,vc(0), vc(15), 0, 0, 0, 0, (void *) gamepad_tabs, NULL, (void *)gamepad_dlg },
5643 { d_stringloader, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5644 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5645 { jwin_button_proc, 90, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5646 { jwin_button_proc, 170, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5647 // 6
5648 { d_dummy_proc, 14, 61, 294, 192, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5649 // 7
5650 { jwin_ctext_proc, 92, 92-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
5651 { jwin_ctext_proc, 92, 120-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_b, NULL, NULL },
5652 { jwin_ctext_proc, 92, 148-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5653 { jwin_ctext_proc, 92, 180-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex1, NULL, NULL },
5654 { jwin_ctext_proc, 92, 212-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex3, NULL, NULL },
5655 { jwin_ctext_proc, 237, 92-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_l, NULL, NULL },
5656 { jwin_ctext_proc, 237, 120-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_r, NULL, NULL },
5657 { jwin_ctext_proc, 237, 148-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_p, NULL, NULL },
5658 { jwin_ctext_proc, 237, 180-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex2, NULL, NULL },
5659 { jwin_ctext_proc, 237, 212-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex4, NULL, NULL },
5660 { jwin_ctext_proc, 92, 244-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_m, NULL, NULL },
5661 // 18
5662 { d_jbutton_proc, 22, 90-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "A", NULL, &Abtn},
5663 { d_jbutton_proc, 22, 118-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "B", NULL, &Bbtn},
5664 { d_jbutton_proc, 22, 146-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Start", NULL, &Sbtn},
5665 { d_jbutton_proc, 22, 178-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "X (EX1)", NULL, &Exbtn1},
5666 { d_jbutton_proc, 22, 210-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX3", NULL, &Exbtn3},
5667 { d_jbutton_proc, 167, 90-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "L", NULL, &Lbtn},
5668 { d_jbutton_proc, 167, 118-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "R", NULL, &Rbtn},
5669 { d_jbutton_proc, 167, 146-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Map", NULL, &Pbtn},
5670 { d_jbutton_proc, 167, 178-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Y (EX2)", NULL, &Exbtn2},
5671 { d_jbutton_proc, 167, 210-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX4", NULL, &Exbtn4},
5672 { d_jbutton_proc, 22, 242-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Menu", NULL, &Mbtn},
5673 // 29
5674 { d_j_clearbutton_proc, 22+91, 90-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Abtn},
5675 { d_j_clearbutton_proc, 22+91, 118-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Bbtn},
5676 { d_j_clearbutton_proc, 22+91, 146-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Sbtn},
5677 { d_j_clearbutton_proc, 22+91, 178-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn1},
5678 { d_j_clearbutton_proc, 22+91, 210-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn3},
5679 { d_j_clearbutton_proc, 167+91, 90-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Lbtn},
5680 { d_j_clearbutton_proc, 167+91, 118-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Rbtn},
5681 { d_j_clearbutton_proc, 167+91, 146-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Pbtn},
5682 { d_j_clearbutton_proc, 167+91, 178-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn2},
5683 { d_j_clearbutton_proc, 167+91, 210-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn4},
5684 { d_j_clearbutton_proc, 22+91, 242-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Mbtn},
5685 // 40
5686 { jwin_frame_proc, 14, 62, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5687 { jwin_frame_proc, 159, 62, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5688 { jwin_text_proc, 30, 68, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Vertical", NULL, NULL },
5689 { jwin_text_proc, 175, 68, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Horizontal", NULL, NULL },
5690 // 44
5691 { jwin_text_proc, 92, 84, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_up, NULL, NULL },
5692 { jwin_text_proc, 92, 112, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_down, NULL, NULL },
5693 { jwin_text_proc, 237, 84, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_left, NULL, NULL },
5694 { jwin_text_proc, 237, 112, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_right, NULL, NULL },
5695 // 48
5696 { d_jbutton_proc, 22, 82, 61, 21, vc(14), vc(11), 0, 0, 0, 0, (void *) "Up", NULL, &DUbtn },
5697 { d_jbutton_proc, 22, 110, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Down", NULL, &DDbtn },
5698 { d_jbutton_proc, 167, 82, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Left", NULL, &DLbtn },
5699 { d_jbutton_proc, 167, 110, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Right", NULL, &DRbtn },
5700 // 52
5701 { d_j_clearbutton_proc, 22+91, 82, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DUbtn},
5702 { d_j_clearbutton_proc, 22+91, 110, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DDbtn},
5703 { d_j_clearbutton_proc, 167+91, 82, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DLbtn},
5704 { d_j_clearbutton_proc, 167+91, 110, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DRbtn},
5705 // 56
5706 { jwin_check_proc, 22, 150, 147, 8, vc(14), vc(1), 0, 0, 1, 0, (void *) "Use Analog Stick/DPad", NULL, NULL },
5707 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5708 };
5709
5710 static int32_t keyboard_keys_list[] =
5711 {
5712 6,7,8,9,10,
5713 11,12,13,14,15,16,17,18,19,20,
5714 21,22,23,24,25,26,27,28,29,30,
5715 31,32,33,34,35,36,37,38,39,40,
5716 -1
5717 };
5718
5719 static int32_t keyboard_dirs_list[] =
5720 {
5721 41,42,43,44,
5722 45,46,47,48,
5723 49,50,51,52,
5724 53,54,55,56,
5725 -1
5726 };
5727
5728 static int32_t keyboard_mods_list[] =
5729 {
5730 57,58,59,60,
5731 61,62,63,64,
5732 65,66,67,68,
5733 69,70,71,72,
5734 -1
5735 };
5736
5737 static TABPANEL keyboard_control_tabs[] =
5738 {
5739 // (text)
5740 { (char *)"Keys", D_SELECTED, keyboard_keys_list, 0, NULL },
5741 { (char *)"Directions", 0, keyboard_dirs_list, 0, NULL },
5742 { (char *)"Cheat Mods", 0, keyboard_mods_list, 0, NULL },
5743 { NULL, 0, NULL, 0, NULL }
5744 };
5745
5746 static DIALOG keyboard_control_dlg[] =
5747 {
5748 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5749 { jwin_win_proc, 8, 39, 304, 240, 0, 0, 0, D_EXIT, 0, 0, (void *) "Keyboard Controls", NULL, NULL },
5750 { jwin_tab_proc, 8+4, 39+23,304-8,240-56,vc(0), vc(15), 0, 0, 0, 0, (void *) keyboard_control_tabs, NULL, (void *)keyboard_control_dlg },
5751 { d_stringloader, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5752 { jwin_button_proc, 90, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5753 { jwin_button_proc, 170, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5754 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5755 // Keys
5756 // 6
5757 { jwin_frame_proc, 14, 80, 148, 105, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5758 { jwin_frame_proc, 158, 80, 148, 105, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5759 { jwin_frame_proc, 14, 181, 292, 67, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5760 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Standard", NULL, NULL },
5761 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Extended", NULL, NULL },
5762 // 11
5763 { jwin_text_proc, 92-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
5764 { jwin_text_proc, 92-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_b, NULL, NULL },
5765 { jwin_text_proc, 92-4, 158, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5766 { jwin_text_proc, 92-4, 190, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex1, NULL, NULL },
5767 { jwin_text_proc, 92-4, 222, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex3, NULL, NULL },
5768 { jwin_text_proc, 237-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_l, NULL, NULL },
5769 { jwin_text_proc, 237-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_r, NULL, NULL },
5770 { jwin_text_proc, 237-4, 158, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_p, NULL, NULL },
5771 { jwin_text_proc, 237-4, 190, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex2, NULL, NULL },
5772 { jwin_text_proc, 237-4, 222, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex4, NULL, NULL },
5773 // 21
5774 { d_kbutton_proc, 22, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "A", NULL, &Akey},
5775 { d_kbutton_proc, 22, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "B", NULL, &Bkey},
5776 { d_kbutton_proc, 22, 156, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Start", NULL, &Skey},
5777 { d_kbutton_proc, 22, 188, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "X (EX1)", NULL, &Exkey1},
5778 { d_kbutton_proc, 22, 220, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX3", NULL, &Exkey3},
5779 { d_kbutton_proc, 167, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "L", NULL, &Lkey},
5780 { d_kbutton_proc, 167, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "R", NULL, &Rkey},
5781 { d_kbutton_proc, 167, 156, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Map", NULL, &Pkey},
5782 { d_kbutton_proc, 167, 188, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Y (EX2)", NULL, &Exkey2},
5783 { d_kbutton_proc, 167, 220, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX4", NULL, &Exkey4},
5784 // 31
5785 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Akey},
5786 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Bkey},
5787 { d_k_clearbutton_proc, 22+91, 156, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Skey},
5788 { d_k_clearbutton_proc, 22+91, 188, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey1},
5789 { d_k_clearbutton_proc, 22+91, 220, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey3},
5790 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Lkey},
5791 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Rkey},
5792 { d_k_clearbutton_proc, 167+91, 156, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Pkey},
5793 { d_k_clearbutton_proc, 167+91, 188, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey2},
5794 { d_k_clearbutton_proc, 167+91, 220, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey4},
5795 // Dirs
5796 // 41
5797 { jwin_frame_proc, 14, 80, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5798 { jwin_frame_proc, 159, 80, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5799 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Vertical", NULL, NULL },
5800 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Horizontal", NULL, NULL },
5801 // 45
5802 { jwin_text_proc, 92-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_up, NULL, NULL },
5803 { jwin_text_proc, 92-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_down, NULL, NULL },
5804 { jwin_text_proc, 237-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_left, NULL, NULL },
5805 { jwin_text_proc, 237-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_right, NULL, NULL },
5806 // 49
5807 { d_kbutton_proc, 22, 100, 61, 21, vc(14), vc(11), 0, 0, 0, 0, (void *) "Up", NULL, &DUkey},
5808 { d_kbutton_proc, 22, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Down", NULL, &DDkey},
5809 { d_kbutton_proc, 167, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Left", NULL, &DLkey},
5810 { d_kbutton_proc, 167, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Right", NULL, &DRkey},
5811 // 53
5812 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DUkey},
5813 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DDkey},
5814 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DLkey},
5815 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DRkey},
5816 // Mods
5817 // 57
5818 { jwin_frame_proc, 14, 80, 148, 140-58, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5819 { jwin_frame_proc, 158, 80, 148, 140-58, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5820 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Left", NULL, NULL },
5821 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Right", NULL, NULL },
5822 // 61
5823 { jwin_text_proc, 92-26, 101, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_leftmod1, NULL, NULL },
5824 { jwin_text_proc, 92-26, 129, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_rightmod1, NULL, NULL },
5825 { jwin_text_proc, 237-4-22,101, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_leftmod2, NULL, NULL },
5826 { jwin_text_proc, 237-4-22,129, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_rightmod2, NULL, NULL },
5827 // 65
5828 { d_kbutton_proc, 22, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Main", NULL, &cheat_modifier_keys[0]},
5829 { d_kbutton_proc, 22, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Second", NULL, &cheat_modifier_keys[2]},
5830 { d_kbutton_proc, 167, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Main", NULL, &cheat_modifier_keys[1]},
5831 { d_kbutton_proc, 167, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Second", NULL, &cheat_modifier_keys[3]},
5832 // 69
5833 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[0]},
5834 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[2]},
5835 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[1]},
5836 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[3]},
5837 // 73
5838 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5839 };
5840
5841 /*
5842 int32_t midi_dp[3] = {0,147,104};
5843 int32_t digi_dp[3] = {1,147,120};
5844 int32_t pan_dp[3] = {0,147,136};
5845 int32_t buf_dp[3] = {0,147,152};
5846 */
5847 int32_t midi_dp[3] = {0,0,0};
5848 int32_t digi_dp[3] = {1,0,0};
5849 int32_t emus_dp[3] = {2,0,0};
5850 int32_t buf_dp[3] = {0,0,0};
5851 int32_t sfx_dp[3] = {3,0,0};
5852 int32_t pan_dp[3] = {0,0,0};
5853
5854 static DIALOG sound_dlg[] =
5855 {
5856 //(dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5857 29 { jwin_win_proc, 0, 0, 320, 178, 0, 0, 0, D_EXIT, 0, 0, (void *) "Sound Settings", NULL, NULL },
5858 29 { d_stringloader, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5859 29 { jwin_button_proc, 58, 148, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5860 29 { jwin_button_proc, 138, 148, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5861 29 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5862 29 { jwin_frame_proc, 10, 28, 300, 112, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
5863 29 { jwin_rtext_proc, 190, 40, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_a, NULL, NULL },
5864 29 { jwin_rtext_proc, 190, 56, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_b, NULL, NULL },
5865 29 { jwin_rtext_proc, 190, 72, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_l, NULL, NULL },
5866 29 { jwin_rtext_proc, 190, 88, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_m, NULL, NULL },
5867 // 10
5868 29 { jwin_rtext_proc, 190, 104, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_r, NULL, NULL },
5869 29 { jwin_rtext_proc, 190, 120, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_s, NULL, NULL },
5870 29 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5871 29 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5872 29 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5873 29 { jwin_slider_proc, 196, 40, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, midi_dp },
5874 29 { jwin_slider_proc, 196, 56, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, digi_dp },
5875 29 { jwin_slider_proc, 196, 72, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, emus_dp },
5876 29 { jwin_slider_proc, 196, 88, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 127, 0, NULL, (void *) set_buf, buf_dp },
5877 29 { jwin_slider_proc, 196, 104, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, sfx_dp },
5878 //20
5879 29 { jwin_slider_proc, 196, 120, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 3, 0, NULL, (void *) set_pan, pan_dp },
5880 29 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5881 29 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5882 29 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5883 29 { jwin_text_proc, 17, 40, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Master MIDI Volume", NULL, NULL },
5884 29 { jwin_text_proc, 17, 56, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Master Digi Volume", NULL, NULL },
5885 29 { jwin_text_proc, 17, 72, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Enhanced Music Volume", NULL, NULL },
5886 29 { jwin_text_proc, 17, 88, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Enhanced Music Buffer", NULL, NULL },
5887 29 { jwin_text_proc, 17, 104, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "SFX Volume", NULL, NULL },
5888 29 { jwin_text_proc, 17, 120, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "SFX Pan", NULL, NULL },
5889 //30
5890 29 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5891 29 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5892 29 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5893 29 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5894 };
5895
5896 char zc_builddate[80];
5897 char zc_aboutstr[80];
5898
5899 static DIALOG about_dlg[] =
5900 {
5901 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
5902 { jwin_win_proc, 68, 52, 184, 154, 0, 0, 0, D_EXIT, 0, 0, (void *) "About", NULL, NULL },
5903 { jwin_button_proc, 140, 176, 41, 21, vc(14), 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5904 { jwin_ctext_proc, 160, 84, 0, 8, vc(0), vc(11), 0, 0, 0, 0, zc_aboutstr, NULL, NULL },
5905 { jwin_ctext_proc, 160, 92, 0, 8, vc(0) , vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5906 { jwin_ctext_proc, 160, 100, 0, 8, vc(0) , vc(11), 0, 0, 0, 0, zc_builddate, NULL, NULL },
5907 { jwin_text_proc, 88, 124, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Coded by:", NULL, NULL },
5908 { jwin_text_proc, 88, 132, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) " Phantom Menace", NULL, NULL },
5909 { jwin_text_proc, 88, 144, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Produced by:", NULL, NULL },
5910 { jwin_text_proc, 88, 152, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) " Armageddon Games", NULL, NULL },
5911 { jwin_frame_proc, 80, 117, 160, 50, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5912 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5913 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5914 };
5915
5916
5917 static DIALOG quest_dlg[] =
5918 {
5919 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
5920 { jwin_win_proc, 68, 25, 184, 190, 0, 0, 0, D_EXIT, 0, 0, (void *) "Quest Info", NULL, NULL },
5921 { jwin_edit_proc, 84, 54, 152, 16, 0, 0, 0, D_READONLY, 100, 0, NULL, NULL, NULL },
5922 { jwin_text_proc, 89, 84, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Number:", NULL, NULL },
5923 { jwin_text_proc, 152, 84, 24, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
5924 { jwin_text_proc, 89, 94, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Version:", NULL, NULL },
5925 { jwin_text_proc, 160, 94, 64, 8, vc(7), vc(11), 0, 0, 0, 0, header_version_nul_term, NULL, NULL },
5926 { jwin_text_proc, 89, 104, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "ZQ Version:", NULL, NULL },
5927 { jwin_text_proc, 184, 104, 64, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5928 { jwin_text_proc, 84, 126, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Title:", NULL, NULL },
5929 { jwin_textbox_proc, 84, 136, 152, 24, 0, 0, 0, 0, 0, 0, QHeader.title, NULL, NULL },
5930 { jwin_text_proc, 84, 168, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Author:", NULL, NULL },
5931 { jwin_textbox_proc, 84, 178, 152, 24, 0, 0, 0, 0, 0, 0, QHeader.author, NULL, NULL },
5932 { jwin_frame_proc, 84, 79, 152, 38, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5933 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5934 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5935 };
5936
5937 static DIALOG triforce_dlg[] =
5938 {
5939 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
5940 { jwin_win_proc, 72, 64, 177, 105, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Triforce Pieces", NULL, NULL },
5941 // 1
5942 { jwin_check_proc, 129, 94, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "1", NULL, NULL },
5943 { jwin_check_proc, 129, 104, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "2", NULL, NULL },
5944 { jwin_check_proc, 129, 114, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "3", NULL, NULL },
5945 { jwin_check_proc, 129, 124, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "4", NULL, NULL },
5946 { jwin_check_proc, 172, 94, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "5", NULL, NULL },
5947 { jwin_check_proc, 172, 104, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "6", NULL, NULL },
5948 { jwin_check_proc, 172, 114, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "7", NULL, NULL },
5949 { jwin_check_proc, 172, 124, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "8", NULL, NULL },
5950 // 9
5951 { jwin_button_proc, 90, 144, 61, 21, vc(0), vc(11), 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
5952 { jwin_button_proc, 170, 144, 61, 21, vc(0), vc(11), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5953 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5954 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5955 };
5956
5957 bool zc_getname(const char *prompt,const char *ext,EXT_LIST *list,const char *def,bool usefilename)
5958 {
5959 go();
5960 int32_t ret=0;
5961 ret = zc_getname_nogo(prompt,ext,list,def,usefilename);
5962 comeback();
5963 return ret != 0;
5964 }
5965
5966
5967 bool zc_getname_nogo(const char *prompt,const char *ext,EXT_LIST *list,const char *def,bool usefilename)
5968 {
5969 if(def!=modulepath)
5970 strcpy(modulepath,def);
5971
5972 if(!usefilename)
5973 {
5974 int32_t i=(int32_t)strlen(modulepath);
5975
5976 while(i>=0 && modulepath[i]!='\\' && modulepath[i]!='/')
5977 modulepath[i--]=0;
5978 }
5979
5980 // int32_t ret = file_select_ex(prompt,modulepath,ext,255,-1,-1);
5981 int32_t ret=0;
5982 int32_t sel=0;
5983
5984 if(list==NULL)
5985 {
5986 ret = jwin_file_select_ex(prompt,modulepath,ext,2048,-1,-1,lfont);
5987 }
5988 else
5989 {
5990 ret = jwin_file_browse_ex(prompt, modulepath, list, &sel, 2048, -1, -1, lfont);
5991 }
5992
5993 return ret!=0;
5994 }
5995
5996 //The Dialogue that loads a ZMOD Module File
5997 int32_t zc_load_zmod_module_file()
5998 {
5999 if ( Playing )
6000 {
6001 jwin_alert("Error","Cannot change module while playing a quest!",NULL,NULL,"O&K",NULL,'k',0,lfont);
6002 return -1;
6003 }
6004 if(!zc_getname("Load Module (.zmod)","zmod",NULL,modulepath,false))
6005 return D_CLOSE;
6006
6007 FILE *tempmodule = fopen(modulepath,"r");
6008
6009 if(tempmodule == NULL)
6010 {
6011 jwin_alert("Error","Cannot open specified file!",NULL,NULL,"O&K",NULL,'k',0,lfont);
6012 return -1;
6013 }
6014
6015
6016 //Set the module path:
6017 memset(moduledata.module_name, 0, sizeof(moduledata.module_name));
6018 strcpy(moduledata.module_name, modulepath);
6019 al_trace("New Module Path is: %s \n", moduledata.module_name);
6020 zc_set_config("ZCMODULE","current_module",moduledata.module_name);
6021 zcm.init(true); //Load the module values.
6022 moduledata.refresh_title_screen = 1;
6023 // refresh_select_screen = 1;
6024 build_biic_list();
6025 return D_O_K;
6026 }
6027
6028 static DIALOG module_info_dlg[] =
6029 {
6030 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
6031
6032
6033 { jwin_win_proc, 0, 0, 200, 200, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "About Current Module", NULL, NULL },
6034 //1
6035 { jwin_text_proc, 10, 20, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"Module:", NULL, NULL },
6036 //2
6037 { jwin_text_proc, 50, 20, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6038 { jwin_text_proc, 10, 30, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"Author:", NULL, NULL },
6039 //4
6040 { jwin_text_proc, 50, 30, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6041 { jwin_text_proc, 10, 40, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6042 { jwin_text_proc, 10, 50, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"Information:", NULL, NULL },
6043 //7
6044
6045 { jwin_text_proc, 10, 60, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6046 { jwin_text_proc, 10, 70, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6047 { jwin_text_proc, 10, 80, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6048 { jwin_text_proc, 10, 90, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6049 { jwin_text_proc, 10, 100, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6050 { jwin_text_proc, 10, 120, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6051 { jwin_text_proc, 10, 130, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6052 { jwin_text_proc, 10, 140, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6053 { jwin_text_proc, 10, 150, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6054
6055 { jwin_button_proc, 40, 160, 50, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6056 { jwin_button_proc, 200-40-50, 160, 50, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6057 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6058 };
6059
6060 void about_zcplayer_module(const char *prompt,int32_t initialval)
6061 {
6062
6063 module_info_dlg[0].dp2 = lfont;
6064 if ( moduledata.moduletitle[0] != 0 )
6065 module_info_dlg[2].dp = (char*)moduledata.moduletitle;
6066
6067 if ( moduledata.moduleauthor[0] != 0 )
6068 module_info_dlg[4].dp = (char*)moduledata.moduleauthor;
6069
6070 if ( moduledata.moduleinfo0[0] != 0 )
6071 module_info_dlg[7].dp = (char*)moduledata.moduleinfo0;
6072 if ( moduledata.moduleinfo1[0] != 0 )
6073 module_info_dlg[8].dp = (char*)moduledata.moduleinfo1;
6074 if ( moduledata.moduleinfo2[0] != 0 )
6075 module_info_dlg[9].dp = (char*)moduledata.moduleinfo2;
6076 if ( moduledata.moduleinfo3[0] != 0 )
6077 module_info_dlg[10].dp = (char*)moduledata.moduleinfo3;
6078 if ( moduledata.moduleinfo4[0] != 0 )
6079 module_info_dlg[11].dp = (char*)moduledata.moduleinfo4;
6080
6081 char module_date[255];
6082 memset(module_date, 0, sizeof(module_date));
6083 sprintf(module_date,"Build Date: %s %s, %d at @ %d:%d %s", dayextension(moduledata.modday).c_str(),
6084 (char*)months[moduledata.modmonth], moduledata.modyear, moduledata.modhour, moduledata.modminute, moduledata.moduletimezone);
6085
6086
6087
6088 char module_vers[255];
6089 memset(module_vers, 0, sizeof(module_vers));
6090 sprintf(module_vers, "Version: %d.%d.%d.%d", moduledata.modver_1, moduledata.modver_2, moduledata.modver_3, moduledata.modver_4);
6091
6092
6093 //sprintf(tilecount,"%d",1);
6094
6095 char module_build[255];
6096 memset(module_build, 0, sizeof(module_build));
6097 if ( moduledata.modbeta )
6098 sprintf(module_build,"Module Build: %d, %s: %d", moduledata.modbuild, (moduledata.modbeta<0) ? "Alpha" : "Beta", moduledata.modbeta );
6099 else
6100 sprintf(module_build,"Module Build: %d", moduledata.modbuild);
6101
6102 module_info_dlg[12].dp = (char*)module_date;
6103 module_info_dlg[13].dp = (char*)module_vers;
6104 module_info_dlg[14].dp = (char*)module_build;
6105
6106 large_dialog(module_info_dlg);
6107
6108 int32_t ret = do_zqdialog(module_info_dlg,-1);
6109 jwin_center_dialog(module_info_dlg);
6110
6111
6112 }
6113
6114 int32_t onAbout_ZCP_Module()
6115 {
6116 about_zcplayer_module("About Module (.zmod)", 0);
6117 return D_O_K;
6118 }
6119
6120 //New Modules Menu for 2.55+
6121 static MENU zcmodule_menu[] =
6122 {
6123 { (char *)"&Load Module...", zc_load_zmod_module_file, NULL, 0, NULL },
6124 { (char *)"&About Module", onAbout_ZCP_Module, NULL, 0, NULL },
6125
6126 { NULL, NULL, NULL, 0, NULL }
6127 };
6128
6129 int32_t onToggleRecordingNewSaves()
6130 {
6131 if (zc_get_config("zeldadx", "replay_new_saves", false))
6132 {
6133 zc_set_config("zeldadx", "replay_new_saves", false);
6134 }
6135 else
6136 {
6137 zc_set_config("zeldadx", "replay_new_saves", true);
6138 jwin_alert("Recording", "Newly created saves will be recorded and written to a replay file.",
6139 NULL,NULL,"OK",NULL,13,27,lfont);
6140 }
6141 return D_O_K;
6142 }
6143
6144 int32_t onToggleSnapshotAllFrames()
6145 {
6146 replay_set_snapshot_all_frames(!replay_is_snapshot_all_frames());
6147 return D_O_K;
6148 }
6149
6150 int32_t onStopReplayOrRecord()
6151 {
6152 if (replay_is_replaying())
6153 {
6154 replay_quit();
6155 }
6156 else if (replay_get_mode() == ReplayMode::Record)
6157 {
6158 if (!replay_get_meta_bool("test_mode"))
6159 {
6160 jwin_alert("Recording", "You cannot stop recording a save file.",
6161 NULL,NULL,"OK",NULL,13,27,lfont);
6162 return D_CLOSE;
6163 }
6164
6165 if (jwin_alert("Stop Recording",
6166 "Save replay to disk and stop recording?",
6167 "This will stop the recording.",
6168 NULL,
6169 "Yes","No",13,27,lfont) != 1)
6170 return D_CLOSE;
6171
6172 replay_save();
6173 replay_stop();
6174 }
6175 return D_O_K;
6176 }
6177
6178 static int32_t handle_on_load_replay(ReplayMode mode)
6179 {
6180 if (Playing)
6181 {
6182 if (jwin_alert("Replay - Warning!",
6183 "Loading a replay will exit the current game.",
6184 "All unsaved progress will be lost.",
6185 "Do you wish to continue?",
6186 "Yes","No",13,27,lfont) != 1)
6187 return D_CLOSE;
6188 }
6189
6190 std::string mode_string = replay_mode_to_string(mode);
6191 mode_string[0] = std::toupper(mode_string[0]);
6192
6193 std::string line_1 = "Select a replay file to play back.";
6194 std::string line_2 = "You won't be able to save, and it won't effect existing saves.";
6195 std::string line_3 = "You can stop the replay and take over manually any time.";
6196 if (mode == ReplayMode::Update)
6197 {
6198 line_1 = "Select a replay file to update.";
6199 line_2 = "WARNING: be sure to back up the zplay file";
6200 line_3 = "and verify that the updated replay works as expected!";
6201 }
6202
6203 if (jwin_alert(mode_string.c_str(),
6204 line_1.c_str(),
6205 line_2.c_str(),
6206 line_3.c_str(),
6207 "OK","Nevermind",13,27,lfont) == 1)
6208 {
6209 char replay_path[2048];
6210 strcpy(replay_path, "replays/");
6211 if (jwin_file_select_ex(
6212 fmt::format("Load Replay (.{})", REPLAY_EXTENSION).c_str(),
6213 replay_path, REPLAY_EXTENSION.c_str(), 2048, -1, -1, lfont) == 0)
6214 return D_CLOSE;
6215
6216 replay_quit();
6217 load_replay_file_deferred(mode, replay_path);
6218 Quit = qRESET;
6219 return D_CLOSE;
6220 }
6221 return D_O_K;
6222 }
6223
6224 int32_t onLoadReplay()
6225 {
6226 return handle_on_load_replay(ReplayMode::Replay);
6227 }
6228
6229 int32_t onLoadReplayAssert()
6230 {
6231 return handle_on_load_replay(ReplayMode::Assert);
6232 }
6233
6234 int32_t onLoadReplayUpdate()
6235 {
6236 return handle_on_load_replay(ReplayMode::Update);
6237 }
6238
6239 int32_t onSaveReplay()
6240 {
6241 if (replay_get_mode() == ReplayMode::Record)
6242 {
6243 if (!replay_get_meta_bool("test_mode"))
6244 {
6245 if (jwin_alert("Save Replay",
6246 "This will save a copy of the replay up to this point.",
6247 "The official replay file will be untouched.",
6248 "Do you wish to continue?",
6249 "Yes","No",13,27,lfont) != 1)
6250 return D_CLOSE;
6251
6252 char replay_path[2048];
6253 strcpy(replay_path, replay_get_replay_path().string().c_str());
6254 if (jwin_file_select_ex(
6255 fmt::format("Save Replay (.{})", REPLAY_EXTENSION).c_str(),
6256 replay_path, REPLAY_EXTENSION.c_str(), 2048, -1, -1, lfont) == 0)
6257 return D_CLOSE;
6258
6259 if (fileexists(replay_path))
6260 {
6261 jwin_alert("Save Replay", "You cannot overwrite an existing file.",
6262 NULL,NULL,"OK",NULL,13,27,lfont);
6263 return D_CLOSE;
6264 }
6265
6266 replay_save(replay_path);
6267 }
6268 else
6269 {
6270 replay_save();
6271 }
6272 }
6273 return D_O_K;
6274 }
6275
6276 static MENU replay_menu[] =
6277 {
6278 { (char *)"Record new saves", onToggleRecordingNewSaves, NULL, 0, NULL },
6279 { (char *)"Stop replay", onStopReplayOrRecord, NULL, 0, NULL },
6280 { (char *)"Load replay", onLoadReplay, NULL, 0, NULL },
6281 { (char *)"Load replay (assert)", onLoadReplayAssert, NULL, 0, NULL },
6282 { (char *)"Load replay (update)", onLoadReplayUpdate, NULL, 0, NULL },
6283 { (char *)"Save replay", onSaveReplay, NULL, 0, NULL },
6284 { (char *)"Enable snapshot all frames", onToggleSnapshotAllFrames,NULL, 0, NULL },
6285
6286 { NULL, NULL, NULL, 0, NULL }
6287 };
6288
6289 static DIALOG credits_dlg[] =
6290 {
6291 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6292 { jwin_win_proc, 40, 38, 241, 173, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Zelda Classic Credits", NULL, NULL },
6293 { jwin_frame_proc, 47, 65, 227, 115, vc(15), vc(1), 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
6294 { d_bitmap_proc, 49, 67, 222, 110, vc(15), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
6295 { jwin_button_proc, 140, 184, 41, 21, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6296 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6297 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6298 };
6299
6300 29 static ListData dmap_list(dmaplist, &font, &a5font);
6301
6302 static DIALOG goto_dlg[] =
6303 {
6304 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6305 { jwin_win_proc, 48, 25, 205, 100, 0, 0, 0, D_EXIT, 0, 0, (void *) "Goto Location", NULL, NULL },
6306 { jwin_button_proc, 90, 176-78, 61, 21, vc(14), 0, 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6307 { jwin_button_proc, 170, 176-78, 61, 21, vc(14), 0, 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6308 { jwin_text_proc, 55, 129-75, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "DMap:", NULL, NULL },
6309 { jwin_droplist_proc, 88, 126-75, 160, 16, 0, 0, 0, 0, 0, 0, (void *) &dmap_list, NULL, NULL },
6310 { jwin_text_proc, 55, 149-75, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Screen:", NULL, NULL },
6311 { jwin_edit_proc, 132, 146-75, 91, 16, 0, 0, 0, 0, 2, 0, NULL, NULL, NULL },
6312 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6313 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6314 };
6315
6316 int32_t onGoTo()
6317 {
6318 bool music = false;
6319 music = music;
6320 sprintf(cheat_goto_screen_str,"%X",cheat_goto_screen);
6321
6322 goto_dlg[0].dp2=lfont;
6323 goto_dlg[4].d2=cheat_goto_dmap;
6324 goto_dlg[6].dp=cheat_goto_screen_str;
6325
6326 clear_keybuf();
6327
6328 large_dialog(goto_dlg);
6329
6330 if(do_zqdialog(goto_dlg,4)==1)
6331 {
6332 // dmap, screen
6333 cheats_enqueue(Cheat::GoTo, goto_dlg[4].d2, zc_min(zc_xtoi(cheat_goto_screen_str),0x7F));
6334 };
6335
6336 return D_O_K;
6337 }
6338
6339 int32_t onGoToComplete()
6340 {
6341 if(!Playing)
6342 {
6343 return D_O_K;
6344 }
6345
6346 system_pal();
6347 music_pause();
6348 pause_all_sfx();
6349 show_mouse(screen);
6350 onGoTo();
6351 eat_buttons();
6352
6353 zc_readrawkey(KEY_ESC);
6354
6355 show_mouse(NULL);
6356 game_pal();
6357 music_resume();
6358 resume_all_sfx();
6359 return D_O_K;
6360 }
6361
6362 int32_t onCredits()
6363 {
6364 go();
6365
6366 BITMAP *win = create_bitmap_ex(8,222,110);
6367
6368 if(!win)
6369 return D_O_K;
6370
6371 int32_t c=0;
6372 int32_t l=0;
6373 int32_t ol=-1;
6374 RLE_SPRITE *rle = (RLE_SPRITE*)(datafile[RLE_CREDITS].dat);
6375 RGB *pal = (RGB*)(datafile[PAL_CREDITS].dat);
6376 PALETTE tmppal;
6377
6378 draw_rle_sprite(win,rle,0,0);
6379 credits_dlg[0].dp2=lfont;
6380 credits_dlg[1].fg = jwin_pal[jcDISABLED_FG];
6381 credits_dlg[2].dp = win;
6382
6383 zc_set_palette_range(black_palette,0,127);
6384
6385 DIALOG_PLAYER *p = init_dialog(credits_dlg,3);
6386
6387 popup_zqdialog_start();
6388
6389 while(update_dialog(p))
6390 {
6391 throttleFPS();
6392 ++c;
6393 l = zc_max((c>>1)-30,0);
6394
6395 if(l > rle->h)
6396 l = c = 0;
6397
6398 if(l > rle->h - 112)
6399 l = rle->h - 112;
6400
6401 clear_bitmap(win);
6402 draw_rle_sprite(win,rle,0,0-l);
6403
6404 if(c<=64)
6405 fade_interpolate(black_palette,pal,tmppal,c,0,127);
6406
6407 zc_set_palette_range(tmppal,0,127);
6408
6409 if(l!=ol)
6410 {
6411 scare_mouse();
6412 d_bitmap_proc(MSG_DRAW,credits_dlg+2,0);
6413 unscare_mouse();
6414 SCRFIX();
6415 ol=l;
6416 }
6417
6418 update_hw_screen();
6419 }
6420
6421 popup_zqdialog_end();
6422 system_pal();
6423
6424 shutdown_dialog(p);
6425 destroy_bitmap(win);
6426 //comeback();
6427
6428 return D_O_K;
6429 }
6430
6431 const char *midilist(int32_t index, int32_t *list_size)
6432 {
6433 if(index<0)
6434 {
6435 *list_size=0;
6436
6437 for(int32_t i=0; i<MAXMIDIS; i++)
6438 if(tunes[i].data)
6439 ++(*list_size);
6440
6441 return NULL;
6442 }
6443
6444 int32_t i=0,m=0;
6445
6446 while(m<=index && i<=MAXMIDIS)
6447 {
6448 if(tunes[i].data)
6449 ++m;
6450
6451 ++i;
6452 }
6453
6454 --i;
6455
6456 if(i==MAXMIDIS && m<index)
6457 return "(null)";
6458
6459 return tunes[i].title;
6460 }
6461
6462 /* ------- MIDI info stuff -------- */
6463
6464 char *text;
6465 midi_info *zmi;
6466 bool dialog_running;
6467 bool listening;
6468
6469 void get_info(int32_t index);
6470
6471 int32_t d_midilist_proc(int32_t msg,DIALOG *d,int32_t c)
6472 {
6473 int32_t d2 = d->d2;
6474 int32_t ret = jwin_droplist_proc(msg,d,c);
6475
6476 if(d2!=d->d2)
6477 {
6478 get_info(d->d2);
6479 }
6480
6481 return ret;
6482 }
6483
6484 int32_t d_listen_proc(int32_t msg,DIALOG *d,int32_t c)
6485 {
6486 /* 'd->d1' is offset from 'd' in DIALOG array to midilist proc */
6487
6488 int32_t ret = jwin_button_proc(msg,d,c);
6489
6490 if(ret == D_CLOSE)
6491 {
6492 // get current midi index
6493 int32_t index = (d+(d->d1))->d2;
6494 int32_t i=0, m=0;
6495
6496 while(m<=index && i<=MAXMIDIS)
6497 {
6498 if(tunes[i].data)
6499 ++m;
6500
6501 ++i;
6502 }
6503
6504 --i;
6505 jukebox(i);
6506 listening = true;
6507 ret = D_O_K;
6508 }
6509
6510 return ret;
6511 }
6512
6513 int32_t d_savemidi_proc(int32_t msg,DIALOG *d,int32_t c)
6514 {
6515 /* 'd->d1' is offset from 'd' in DIALOG array to midilist proc */
6516
6517 int32_t ret = jwin_button_proc(msg,d,c);
6518
6519 if(ret == D_CLOSE)
6520 {
6521 // get current midi index
6522 int32_t index = (d+(d->d1))->d2;
6523 int32_t i=0, m=0;
6524
6525 while(m<=index && i<=MAXMIDIS)
6526 {
6527 if(tunes[i].data)
6528 ++m;
6529
6530 ++i;
6531 }
6532
6533 --i;
6534
6535 // get file name
6536
6537 int32_t sel=0;
6538 //struct ffblk f;
6539 char title[40] = "Save MIDI: ";
6540 char fname[2048];
6541 memset(fname,0,2048);
6542 static EXT_LIST list[] =
6543 {
6544 { (char *)"MIDI files (*.mid)", (char *)"mid" },
6545 { (char *)"HTML files (*.html, *.html)", (char *)"htm html" },
6546 { NULL, NULL }
6547 };
6548
6549 strcpy(title+11, tunes[i].title);
6550 title[39] = '\0';
6551
6552 if(jwin_file_browse_ex(title, fname, list, &sel, 2048, -1, -1, lfont)==0)
6553 goto done;
6554
6555 if(exists(fname))
6556 {
6557 if(jwin_alert(title, fname, "already exists.", "Overwrite it?", "&Yes","&No",'y','n',lfont)==2)
6558 goto done;
6559 }
6560
6561 // save midi i
6562
6563 if(save_midi(fname, (MIDI*)tunes[i].data) != 0)
6564 jwin_alert(title, "Error saving MIDI to", fname, NULL, "Darn", NULL,13,27,lfont);
6565
6566 done:
6567 chop_path(fname);
6568 ret = D_REDRAW;
6569 }
6570
6571 return ret;
6572 }
6573
6574 29 static ListData midi_list(midilist, &font, &a5font);
6575
6576 static DIALOG midi_dlg[] =
6577 {
6578 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6579 { jwin_win_proc, 8, 28, 304, 184, 0, 0, 0, D_EXIT, 0, 0, (void *) "MIDI Info", NULL, NULL },
6580 { jwin_text_proc, 32, 60, 40, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Tune:", NULL, NULL },
6581 { d_midilist_proc, 80, 56, 192, 16, 0, 0, 0, 0, 0, 0, (void *) &midi_list, NULL, NULL },
6582 { jwin_textbox_proc, 15, 80, 290, 96, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6583 { d_listen_proc, 24, 183, 72, 21, 0, 0, 'l', D_EXIT, -2, 0, (void *) "&Listen", NULL, NULL },
6584 { d_savemidi_proc, 108, 183, 72, 21, 0, 0, 's', D_EXIT, -3, 0, (void *) "&Save", NULL, NULL },
6585 { jwin_button_proc, 236, 183, 61, 21, 0, 0, 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
6586 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6587 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6588 };
6589
6590 void get_info(int32_t index)
6591 {
6592 int32_t i=0, m=0;
6593
6594 while(m<=index && i<=MAXMIDIS)
6595 {
6596 if(tunes[i].data)
6597 ++m;
6598
6599 ++i;
6600 }
6601
6602 --i;
6603
6604 if(i==MAXMIDIS && m<index)
6605 strcpy(text,"(null)");
6606 else
6607 {
6608 get_midi_info((MIDI*)tunes[i].data,zmi);
6609 get_midi_text((MIDI*)tunes[i].data,zmi,text);
6610 }
6611
6612 midi_dlg[0].dp2=lfont;
6613 midi_dlg[3].dp = text;
6614 midi_dlg[3].d1 = midi_dlg[3].d2 = 0;
6615 midi_dlg[5].flags = (tunes[i].flags&tfDISABLESAVE) ? D_DISABLED : D_EXIT;
6616
6617 if(dialog_running)
6618 {
6619 scare_mouse();
6620 jwin_textbox_proc(MSG_DRAW,midi_dlg+3,0);
6621 d_savemidi_proc(MSG_DRAW,midi_dlg+5,0);
6622 unscare_mouse();
6623 }
6624 }
6625
6626 int32_t onMIDICredits()
6627 {
6628 text = (char*)malloc(4096);
6629 zmi = (midi_info*)malloc(sizeof(midi_info));
6630
6631 if(!text || !zmi)
6632 {
6633 jwin_alert(NULL,"Not enough memory",NULL,NULL,"OK",NULL,13,27,lfont);
6634 return D_O_K;
6635 }
6636
6637 bool do_pause_midi = midi_pos >= 0 && currmidi;
6638 auto restore_midi = currmidi;
6639 if(do_pause_midi)
6640 {
6641 paused_midi_pos = midi_pos;
6642 stop_midi();
6643 midi_paused=true;
6644 midi_suspended = midissuspHALTED;
6645 }
6646
6647 midi_dlg[0].dp2=lfont;
6648 midi_dlg[2].d1 = 0;
6649 midi_dlg[2].d2 = 0;
6650 midi_dlg[4].flags = D_EXIT;
6651 midi_dlg[5].flags = (tunes[midi_dlg[2].d1].flags&tfDISABLESAVE) ? D_DISABLED : D_EXIT;
6652
6653 listening = false;
6654 dialog_running=false;
6655 get_info(0);
6656
6657 dialog_running=true;
6658
6659 large_dialog(midi_dlg);
6660
6661 do_zqdialog(midi_dlg,0);
6662 dialog_running=false;
6663
6664 if(listening)
6665 music_stop();
6666
6667 if(do_pause_midi)
6668 {
6669 midi_suspended = midissuspRESUME;
6670 currmidi = restore_midi;
6671 midi_pos = paused_midi_pos;
6672 }
6673
6674 if(text) free(text);
6675 if(zmi) free(zmi);
6676 return D_O_K;
6677 }
6678
6679 int32_t onAbout()
6680 {
6681 char buf1[80]={0};
6682 std::ostringstream oss;
6683 sprintf(buf1,"%s (%s), Version: %s", ZC_PLAYER_NAME,PROJECT_NAME,ZC_PLAYER_V);
6684 oss << buf1 << '\n';
6685 sprintf(buf1, "%s, Build %d", ALPHA_VER_STR, VERSION_BUILD);
6686 oss << buf1 << '\n';
6687 sprintf(buf1,"Build Date: %s %s, %d at @ %s %s", dayextension(BUILDTM_DAY).c_str(), (char*)months[BUILDTM_MONTH], BUILDTM_YEAR, __TIME__, __TIMEZONE__);
6688 oss << buf1 << '\n';
6689 sprintf(buf1, "Built By: %s", DEV_SIGNOFF);
6690 oss << buf1 << '\n';
6691 sprintf(buf1, "Tag: %s", getReleaseTag());
6692 oss << buf1 << '\n';
6693
6694 InfoDialog("About ZC", oss.str()).show();
6695 return D_O_K;
6696 }
6697
6698 int32_t onQuest()
6699 {
6700 char fname[100];
6701 strcpy(fname, get_filename(qstpath));
6702 quest_dlg[0].dp2=lfont;
6703 quest_dlg[1].dp = fname;
6704
6705 if(QHeader.quest_number==0)
6706 sprintf(str_a,"Custom");
6707 else
6708 sprintf(str_a,"%d",QHeader.quest_number);
6709
6710 sprintf(str_s,"%s",VerStr(QHeader.zelda_version));
6711
6712 quest_dlg[11].d1 = quest_dlg[9].d1 = 0;
6713 quest_dlg[11].d2 = quest_dlg[9].d2 = 0;
6714
6715 large_dialog(quest_dlg);
6716
6717 do_zqdialog(quest_dlg, 0);
6718 return D_O_K;
6719 }
6720
6721 void call_vidmode_dlg();
6722 int32_t onVidMode()
6723 {
6724 call_vidmode_dlg();
6725 return D_O_K;
6726 }
6727
6728 #define addToHash(c,b,h) if(h->find(c ## key) == h->end()) \
6729 {(*h)[c ## key]=true;} else { if ( c ## key != 0 ) b = false;}
6730 //Added an extra statement, so that if the key is cleared to 0, the cleared
6731 //keybinding status need not be unique. -Z ( 1st April, 2019 )
6732
6733 void load_ukeys(int32_t* arr)
6734 {
6735 arr[ukey_a] = Akey;
6736 arr[ukey_b] = Bkey;
6737 arr[ukey_s] = Skey;
6738 arr[ukey_l] = Lkey;
6739 arr[ukey_r] = Rkey;
6740 arr[ukey_p] = Pkey;
6741 arr[ukey_ex1] = Exkey1;
6742 arr[ukey_ex2] = Exkey2;
6743 arr[ukey_ex3] = Exkey3;
6744 arr[ukey_ex4] = Exkey4;
6745 arr[ukey_du] = DUkey;
6746 arr[ukey_dd] = DDkey;
6747 arr[ukey_dl] = DLkey;
6748 arr[ukey_dr] = DRkey;
6749 arr[ukey_mod1a] = cheat_modifier_keys[0];
6750 arr[ukey_mod1b] = cheat_modifier_keys[1];
6751 arr[ukey_mod2a] = cheat_modifier_keys[2];
6752 arr[ukey_mod2b] = cheat_modifier_keys[3];
6753 };
6754
6755 static const char* ukey_names[] = {
6756 "A", "B", "Start", "L", "R", "Map",
6757 "Ex1", "Ex2", "Ex3", "Ex4", "Up", "Down",
6758 "Left", "Right", "Cheat Mod L1", "Cheat Mod L2",
6759 "Cheat Mod R1", "Cheat Mod R2",
6760 };
6761 std::string get_ukey_name(int32_t k)
6762 {
6763 if (k < num_ukey) return ukey_names[k];
6764 return "";
6765 }
6766
6767 int32_t onKeyboard()
6768 {
6769 int32_t a = Akey;
6770 int32_t b = Bkey;
6771 int32_t s = Skey;
6772 int32_t l = Lkey;
6773 int32_t r = Rkey;
6774 int32_t p = Pkey;
6775 int32_t ex1 = Exkey1;
6776 int32_t ex2 = Exkey2;
6777 int32_t ex3 = Exkey3;
6778 int32_t ex4 = Exkey4;
6779 int32_t du = DUkey;
6780 int32_t dd = DDkey;
6781 int32_t dl = DLkey;
6782 int32_t dr = DRkey;
6783 int32_t mod1a = cheat_modifier_keys[0];
6784 int32_t mod1b = cheat_modifier_keys[1];
6785 int32_t mod2a = cheat_modifier_keys[2];
6786 int32_t mod2b = cheat_modifier_keys[3];
6787 bool done=false;
6788 int32_t ret;
6789
6790 keyboard_control_dlg[0].dp2=lfont;
6791
6792 large_dialog(keyboard_control_dlg);
6793
6794 while(!done)
6795 {
6796 ret = do_zqdialog(keyboard_control_dlg,3);
6797
6798 if(ret==3) // OK
6799 {
6800 int32_t ukeys[num_ukey];
6801 load_ukeys(ukeys);
6802 std::vector<std::string> uniqueError;
6803 for(int32_t q = 0; q < num_ukey; ++q)
6804 {
6805 for(int32_t p = q+1; p < num_ukey; ++p)
6806 {
6807 if(ukeys[q] == ukeys[p] && ukeys[q] != 0)
6808 {
6809 char buf[64];
6810 sprintf(buf, "'%s' conflicts with '%s'", get_ukey_name(q).c_str(), get_ukey_name(p).c_str());
6811 std::string str(buf);
6812 uniqueError.push_back(str);
6813 }
6814 }
6815 }
6816 if(uniqueError.size() == 0)
6817 {
6818 done = true;
6819 save_control_configs(true);
6820 }
6821 else
6822 {
6823 box_start(1, "Duplicate Keys", get_custom_font_a5(CFONT_TITLE), get_custom_font_a5(CFONT_DLG), false, keyboard_control_dlg[0].w,keyboard_control_dlg[0].h, 2);
6824 box_out("Cannot have duplicate keybinds!"); box_eol();
6825 for(std::vector<std::string>::iterator it = uniqueError.begin();
6826 it != uniqueError.end(); ++it)
6827 {
6828 box_out((*it).c_str()); box_eol();
6829 }
6830 box_end(true);
6831 }
6832 }
6833 else // Cancel
6834 {
6835 Akey = a;
6836 Bkey = b;
6837 Skey = s;
6838 Lkey = l;
6839 Rkey = r;
6840 Pkey = p;
6841 Exkey1 = ex1;
6842 Exkey2 = ex2;
6843 Exkey3 = ex3;
6844 Exkey4 = ex4;
6845 DUkey = du;
6846 DDkey = dd;
6847 DLkey = dl;
6848 DRkey = dr;
6849 cheat_modifier_keys[0] = mod1a;
6850 cheat_modifier_keys[1] = mod1b;
6851 cheat_modifier_keys[2] = mod2a;
6852 cheat_modifier_keys[3] = mod2b;
6853
6854 done=true;
6855 }
6856
6857 rest(1);
6858 }
6859
6860 return D_O_K;
6861 }
6862
6863 int32_t onGamepad()
6864 {
6865 int32_t a = Abtn;
6866 int32_t b = Bbtn;
6867 int32_t s = Sbtn;
6868 int32_t l = Lbtn;
6869 int32_t r = Rbtn;
6870 int32_t m = Mbtn;
6871 int32_t p = Pbtn;
6872 int32_t ex1 = Exbtn1;
6873 int32_t ex2 = Exbtn2;
6874 int32_t ex3 = Exbtn3;
6875 int32_t ex4 = Exbtn4;
6876 int32_t up = DUbtn;
6877 int32_t down = DDbtn;
6878 int32_t left = DLbtn;
6879 int32_t right = DRbtn;
6880
6881 gamepad_dlg[0].dp2=lfont;
6882 if(analog_movement)
6883 gamepad_dlg[56].flags|=D_SELECTED;
6884 else
6885 gamepad_dlg[56].flags&=~D_SELECTED;
6886
6887 large_dialog(gamepad_dlg);
6888
6889 int32_t ret = do_zqdialog(gamepad_dlg,4);
6890
6891 if(ret == 4) //OK
6892 {
6893 analog_movement = gamepad_dlg[56].flags&D_SELECTED;
6894 save_control_configs(false);
6895 }
6896 else //Cancel
6897 {
6898 Abtn = a;
6899 Bbtn = b;
6900 Sbtn = s;
6901 Lbtn = l;
6902 Rbtn = r;
6903 Mbtn = m;
6904 Pbtn = p;
6905 Exbtn1 = ex1;
6906 Exbtn2 = ex2;
6907 Exbtn3 = ex3;
6908 Exbtn4 = ex4;
6909 DUbtn = up;
6910 DDbtn = down;
6911 DLbtn = left;
6912 DRbtn = right;
6913 }
6914
6915 return D_O_K;
6916 }
6917
6918 int32_t onCheatKeys()
6919 {
6920 int32_t oldcheats[Cheat::Last][2];
6921 memcpy(oldcheats, cheatkeys, sizeof(cheatkeys));
6922
6923 bool done=false;
6924
6925 while(!done)
6926 {
6927 bool confirm = false;
6928 CheatKeysDialog(&confirm).show();
6929 if(confirm) // OK
6930 {
6931 std::vector<std::string> uniqueError;
6932 char buf[512];
6933 for(size_t q = 1; q < Cheat::Last; ++q)
6934 {
6935 if(cheatkeys[q][1] && !cheatkeys[q][0])
6936 {
6937 cheatkeys[q][0] = cheatkeys[q][1];
6938 cheatkeys[q][1] = 0;
6939 }
6940 }
6941 for(size_t q = 1; q < Cheat::Last; ++q)
6942 {
6943 if(!bindable_cheat((Cheat)q)) continue;
6944 for(size_t p = q+1; p < Cheat::Last; ++p)
6945 {
6946 if(!bindable_cheat((Cheat)p)) continue;
6947 for(size_t q2 = 0; q2 <= 1; ++q2)
6948 for(size_t p2 = 0; p2 <= 1; ++p2)
6949 {
6950 if(cheatkeys[q][q2] == cheatkeys[p][p2] && cheatkeys[q][q2] != 0)
6951 {
6952 uniqueError.push_back(fmt::format("'{}' ({}) conflicts with '{}' ({}) - both '{}'",
6953 cheat_to_string((Cheat)q), q2?"Alt":"Main",
6954 cheat_to_string((Cheat)p), p2?"Alt":"Main",
6955 get_keystr(cheatkeys[q][q2])));
6956 }
6957 }
6958 }
6959 }
6960 if(uniqueError.size() == 0)
6961 {
6962 done = true;
6963 save_cheatkeys();
6964 }
6965 else
6966 {
6967 box_start(1, "Duplicate Keys", get_custom_font_a5(CFONT_TITLE), get_custom_font_a5(CFONT_DLG), false, 500,400, 2);
6968 box_out("Cannot have duplicate keybinds!"); box_eol();
6969 for(std::vector<std::string>::iterator it = uniqueError.begin();
6970 it != uniqueError.end(); ++it)
6971 {
6972 box_out((*it).c_str()); box_eol();
6973 }
6974 box_end(true);
6975 }
6976 }
6977 else // Cancel
6978 {
6979 memcpy(cheatkeys, oldcheats, sizeof(cheatkeys));
6980 done=true;
6981 }
6982 rest(1);
6983 }
6984
6985 return D_O_K;
6986 }
6987
6988 int32_t onSound()
6989 {
6990 if ( FFCore.coreflags&FFCORE_SCRIPTED_MIDI_VOLUME )
6991 {
6992 master_volume(-1,((int32_t)FFCore.usr_midi_volume));
6993 }
6994 if ( FFCore.coreflags&FFCORE_SCRIPTED_DIGI_VOLUME )
6995 {
6996 master_volume((int32_t)(FFCore.usr_digi_volume),1);
6997 }
6998 if ( FFCore.coreflags&FFCORE_SCRIPTED_MUSIC_VOLUME )
6999 {
7000 emusic_volume = (int32_t)FFCore.usr_music_volume;
7001 }
7002 if ( FFCore.coreflags&FFCORE_SCRIPTED_SFX_VOLUME )
7003 {
7004 sfx_volume = (int32_t)FFCore.usr_sfx_volume;
7005 }
7006 if ( FFCore.coreflags&FFCORE_SCRIPTED_PANSTYLE )
7007 {
7008 pan_style = (int32_t)FFCore.usr_panstyle;
7009 }
7010
7011 int32_t m = midi_volume;
7012 int32_t d = digi_volume;
7013 int32_t e = emusic_volume;
7014 int32_t b = zcmusic_bufsz;
7015 int32_t s = sfx_volume;
7016 int32_t p = pan_style;
7017 pan_style = vbound(pan_style,0,3);
7018
7019 sound_dlg[0].dp2=lfont;
7020
7021 large_dialog(sound_dlg);
7022
7023 midi_dp[1] = sound_dlg[6].x;
7024 midi_dp[2] = sound_dlg[6].y;
7025 digi_dp[1] = sound_dlg[7].x;
7026 digi_dp[2] = sound_dlg[7].y;
7027 emus_dp[1] = sound_dlg[8].x;
7028 emus_dp[2] = sound_dlg[8].y;
7029 buf_dp[1] = sound_dlg[9].x;
7030 buf_dp[2] = sound_dlg[9].y;
7031 sfx_dp[1] = sound_dlg[10].x;
7032 sfx_dp[2] = sound_dlg[10].y;
7033 pan_dp[1] = sound_dlg[11].x;
7034 pan_dp[2] = sound_dlg[11].y;
7035 sound_dlg[15].d2 = (midi_volume==255) ? 32 : midi_volume>>3;
7036 sound_dlg[16].d2 = (digi_volume==255) ? 32 : digi_volume>>3;
7037 sound_dlg[17].d2 = (emusic_volume==255) ? 32 : emusic_volume>>3;
7038 sound_dlg[18].d2 = zcmusic_bufsz;
7039 sound_dlg[19].d2 = (sfx_volume==255) ? 32 : sfx_volume>>3;
7040 sound_dlg[20].d2 = pan_style;
7041
7042 int32_t ret = do_zqdialog(sound_dlg,1);
7043
7044 if(ret==2)
7045 {
7046 master_volume(digi_volume,midi_volume);
7047
7048 for(int32_t i=0; i<WAV_COUNT; ++i)
7049 {
7050 //allegro assertion fails when passing in -1 as voice -DD
7051 if(sfx_voice[i] > 0)
7052 voice_set_volume(sfx_voice[i], sfx_volume);
7053 }
7054 zc_set_config(sfx_sect,"digi",digi_volume);
7055 zc_set_config(sfx_sect,"midi",midi_volume);
7056 zc_set_config(sfx_sect,"sfx",sfx_volume);
7057 zc_set_config(sfx_sect,"emusic",emusic_volume);
7058 zc_set_config(sfx_sect,"pan",pan_style);
7059 zc_set_config(sfx_sect,"zcmusic_bufsz",zcmusic_bufsz);
7060 }
7061 else
7062 {
7063 midi_volume = m;
7064 digi_volume = d;
7065 emusic_volume = e;
7066 zcmusic_bufsz = b;
7067 sfx_volume = s;
7068 pan_style = p;
7069 }
7070
7071 return D_O_K;
7072 }
7073
7074 int32_t queding(char const* s1, char const* s2, char const* s3)
7075 {
7076 return jwin_alert(ZC_str,s1,s2,s3,"&Yes","&No",'y','n',lfont);
7077 }
7078
7079 int32_t onQuit()
7080 {
7081 if(Playing)
7082 {
7083 int32_t ret=0;
7084
7085 if(get_bit(quest_rules, qr_NOCONTINUE))
7086 {
7087 if(standalone_mode)
7088 {
7089 ret=queding("End current game?",
7090 "The continue screen is disabled; the game",
7091 "will be reloaded from the last save.");
7092 }
7093 else
7094 {
7095 ret=queding("End current game?",
7096 "The continue screen is disabled. You will",
7097 "be returned to the file select screen.");
7098 }
7099 }
7100 else
7101 ret=queding("End current game?",NULL,NULL);
7102
7103 if(ret==1)
7104 {
7105 disableClickToFreeze=false;
7106 Quit=qQUIT;
7107
7108 // Trying to evade a door repair charge?
7109 if(repaircharge)
7110 {
7111 game->change_drupy(-repaircharge);
7112 repaircharge=0;
7113 }
7114
7115 return D_CLOSE;
7116 }
7117 }
7118
7119 return D_O_K;
7120 }
7121
7122 int32_t onTryQuitMenu()
7123 {
7124 return onTryQuit(true);
7125 }
7126
7127 int32_t onTryQuit(bool inMenu)
7128 {
7129 if(Playing && !(GameFlags & GAMEFLAG_NO_F6))
7130 {
7131 if(get_bit(quest_rules,qr_OLD_F6))
7132 {
7133 if(inMenu) onQuit();
7134 else /*if(!get_bit(quest_rules, qr_NOCONTINUE))*/ f_Quit(qQUIT);
7135 }
7136 else
7137 {
7138 disableClickToFreeze=false;
7139 GameFlags |= GAMEFLAG_TRYQUIT;
7140 }
7141 return D_CLOSE;
7142 }
7143
7144 return D_O_K;
7145 }
7146
7147 int32_t onReset()
7148 {
7149 if(queding(" Reset system? ",NULL,NULL)==1)
7150 {
7151 disableClickToFreeze=false;
7152 Quit=qRESET;
7153 replay_quit();
7154 return D_CLOSE;
7155 }
7156
7157 return D_O_K;
7158 }
7159
7160 int32_t onExit()
7161 {
7162 if(queding(" Quit Zelda Classic? ",NULL,NULL)==1)
7163 {
7164 Quit=qEXIT;
7165 return D_CLOSE;
7166 }
7167
7168 return D_O_K;
7169 }
7170
7171 int32_t onTitle_NES()
7172 {
7173 title_version=0;
7174 zc_set_config(cfg_sect,"title",title_version);
7175 return D_O_K;
7176 }
7177 int32_t onTitle_DX()
7178 {
7179 title_version=1;
7180 zc_set_config(cfg_sect,"title",title_version);
7181 return D_O_K;
7182 }
7183 int32_t onTitle_25()
7184 {
7185 title_version=2;
7186 zc_set_config(cfg_sect,"title",title_version);
7187 return D_O_K;
7188 }
7189
7190 int32_t onDebug()
7191 {
7192 if(debug_enabled)
7193 set_debug(!get_debug());
7194 return D_O_K;
7195 }
7196
7197 int32_t onHeartBeep()
7198 {
7199 heart_beep=!heart_beep;
7200 zc_set_config(cfg_sect,"heart_beep",heart_beep);
7201 return D_O_K;
7202 }
7203
7204 int32_t onSaveIndicator()
7205 {
7206 use_save_indicator=!use_save_indicator;
7207 zc_set_config(cfg_sect,"save_indicator",use_save_indicator);
7208 return D_O_K;
7209 }
7210
7211 int32_t onEpilepsy()
7212 {
7213 if(jwin_alert3(
7214 "Epilepsy Flash Reduction",
7215 "Enabling this will reduce the intensity of flashing and screen wave effects.",
7216 "Disabling this will restore standard flash and wavy behaviour.",
7217 "Proceed?",
7218 "&Yes",
7219 "&No",
7220 NULL,
7221 'y',
7222 'n',
7223 0,
7224 lfont) == 1)
7225 {
7226 epilepsyFlashReduction = epilepsyFlashReduction ? 0 : 1;
7227 zc_set_config("zeldadx","checked_epilepsy",1);
7228 zc_set_config(cfg_sect,"epilepsy_flash_reduction",epilepsyFlashReduction);
7229 }
7230 return D_O_K;
7231 }
7232
7233 int32_t onTriforce()
7234 {
7235 for(int32_t i=0; i<MAXINITTABS; ++i)
7236 {
7237 init_tabs[i].flags&=~D_SELECTED;
7238 }
7239
7240 init_tabs[3].flags=D_SELECTED;
7241 return onCheatConsole();
7242 /*triforce_dlg[0].dp2=lfont;
7243 for(int32_t i=1; i<=8; i++)
7244 triforce_dlg[i].flags = (game->lvlitems[i] & liTRIFORCE) ? D_SELECTED : 0;
7245
7246 if(do_zqdialog (triforce_dlg,-1)==9)
7247 {
7248 for(int32_t i=1; i<=8; i++)
7249 {
7250 game->lvlitems[i] &= ~liTRIFORCE;
7251 game->lvlitems[i] |= (triforce_dlg[i].flags & D_SELECTED) ? liTRIFORCE : 0;
7252 }
7253 }
7254 return D_O_K;*/
7255 }
7256
7257 bool rc = false;
7258 /*
7259 int32_t onEquipment()
7260 {
7261 for (int32_t i=0; i<MAXINITTABS; ++i)
7262 {
7263 init_tabs[i].flags&=~D_SELECTED;
7264 }
7265 init_tabs[0].flags=D_SELECTED;
7266 return onCheatConsole();
7267 }
7268 */
7269
7270 int32_t onItems()
7271 {
7272 for(int32_t i=0; i<MAXINITTABS; ++i)
7273 {
7274 init_tabs[i].flags&=~D_SELECTED;
7275 }
7276
7277 init_tabs[1].flags=D_SELECTED;
7278 return onCheatConsole();
7279 }
7280
7281 int32_t onLife()
7282 {
7283 int value = vbound(getnumber("Life",game->get_life()),1,game->get_maxlife());
7284 cheats_enqueue(Cheat::Life, value);
7285 return D_O_K;
7286 }
7287
7288 int32_t onHeartC()
7289 {
7290 int max_life = vbound(getnumber("Heart Containers",game->get_maxlife()/game->get_hp_per_heart()),1,4095) * game->get_hp_per_heart();
7291 int life = vbound(getnumber("Life",game->get_life()/game->get_hp_per_heart()),1,max_life/game->get_hp_per_heart())*game->get_hp_per_heart();
7292 cheats_enqueue(Cheat::MaxLife, max_life);
7293 cheats_enqueue(Cheat::Life, life);
7294 return D_O_K;
7295 }
7296
7297 int32_t onMagicC()
7298 {
7299 int max_magic = vbound(getnumber("Magic Containers",game->get_maxmagic()/game->get_mp_per_block()),0,2047) * game->get_mp_per_block();
7300 int magic = vbound(getnumber("Magic",game->get_magic()/game->get_mp_per_block()),0,game->get_maxmagic()/game->get_mp_per_block())*game->get_mp_per_block();
7301 cheats_enqueue(Cheat::MaxMagic, max_magic);
7302 cheats_enqueue(Cheat::Magic, magic);
7303 return D_O_K;
7304 }
7305
7306 int32_t onRupies()
7307 {
7308 int value = vbound(getnumber("Rupees",game->get_rupies()),0,game->get_maxcounter(1));
7309 cheats_enqueue(Cheat::Rupies, value);
7310 return D_O_K;
7311 }
7312
7313 int32_t onMaxBombs()
7314 {
7315 int value = vbound(getnumber("Max Bombs",game->get_maxbombs()),0,0xFFFF);
7316 cheats_enqueue(Cheat::MaxBombs, value);
7317 cheats_enqueue(Cheat::Bombs, value);
7318 return D_O_K;
7319 }
7320
7321 int32_t onRefillLife()
7322 {
7323 cheats_enqueue(Cheat::Life, game->get_maxlife());
7324 return D_O_K;
7325 }
7326 int32_t onRefillMagic()
7327 {
7328 cheats_enqueue(Cheat::Magic, game->get_maxmagic());
7329 return D_O_K;
7330 }
7331 int32_t onClock()
7332 {
7333 cheats_enqueue(Cheat::Clock);
7334 return D_O_K;
7335 }
7336
7337 int32_t onQstPath()
7338 {
7339 char path[2048];
7340
7341 chop_path(qstdir);
7342 strcpy(path,qstdir);
7343
7344 go();
7345
7346 if(jwin_dfile_select_ex("Quest File Directory", path, "qst", 2048, -1, -1, lfont))
7347 {
7348 chop_path(path);
7349 fix_filename_case(path);
7350 fix_filename_slashes(path);
7351 strcpy(qstdir,path);
7352 strcpy(qstpath,qstdir);
7353 }
7354
7355 comeback();
7356 return D_O_K;
7357 }
7358
7359 #include "dialog/cheat_dialog.h"
7360 int32_t onCheat()
7361 {
7362 call_setcheat_dialog();
7363 game->set_cheat(maxcheat);
7364 if(cheat) game->did_cheat(true);
7365 return D_O_K;
7366 }
7367
7368 int32_t onCheatRupies()
7369 {
7370 cheats_enqueue(Cheat::Rupies, game->get_maxcounter(1));
7371 return D_O_K;
7372 }
7373
7374 int32_t onCheatArrows()
7375 {
7376 cheats_enqueue(Cheat::Arrows, game->get_maxarrows());
7377 return D_O_K;
7378 }
7379
7380 int32_t onCheatBombs()
7381 {
7382 cheats_enqueue(Cheat::Bombs, game->get_maxbombs(), game->get_maxcounter(6));
7383 return D_O_K;
7384 }
7385
7386 // *** screen saver
7387
7388 6510614 int32_t after_time()
7389 {
7390
1/2
✓ Branch 0 taken 6510614 times.
✗ Branch 1 not taken.
6510614 if(ss_enable == 0)
7391 return INT_MAX;
7392
7393
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6510614 times.
6510614 if(ss_after <= 0)
7394 return 5 * 60;
7395
7396
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6510614 times.
6510614 if(ss_after <= 3)
7397 return ss_after * 15 * 60;
7398
7399
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6510614 times.
6510614 if(ss_after <= 13)
7400 return (ss_after - 3) * 60 * 60;
7401
7402 6510614 return MAX_IDLE + 1;
7403 6510614 }
7404
7405 static const char *after_str[15] =
7406 {
7407 " 5 sec", "15 sec", "30 sec", "45 sec", " 1 min", " 2 min", " 3 min",
7408 " 4 min", " 5 min", " 6 min", " 7 min", " 8 min", " 9 min", "10 min",
7409 "Never"
7410 };
7411
7412 const char *after_list(int32_t index, int32_t *list_size)
7413 {
7414 if(index < 0)
7415 {
7416 *list_size = 15;
7417 return NULL;
7418 }
7419
7420 return after_str[index];
7421 }
7422
7423 29 static ListData after__list(after_list, &font, &a5font);
7424
7425 static DIALOG scrsaver_dlg[] =
7426 {
7427 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
7428 29 { jwin_win_proc, 32, 64, 256, 136, 0, 0, 0, D_EXIT, 0, 0, (void *) "Screen Saver Settings", NULL, NULL },
7429 29 { jwin_frame_proc, 42, 92, 236, 70, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
7430 29 { jwin_text_proc, 60, 104, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Run After", NULL, NULL },
7431 29 { jwin_text_proc, 60, 128, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Speed", NULL, NULL },
7432 29 { jwin_text_proc, 60, 144, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Density", NULL, NULL },
7433 29 { jwin_droplist_proc, 144, 100, 96, 16, 0, 0, 0, 0, 0, 0, (void *) &after__list, NULL, NULL },
7434 29 { jwin_slider_proc, 144, 128, 116, 8, vc(0), jwin_pal[jcBOX], 0, 0, 6, 0, NULL, NULL, NULL },
7435 29 { jwin_slider_proc, 144, 144, 116, 8, vc(0), jwin_pal[jcBOX], 0, 0, 6, 0, NULL, NULL, NULL },
7436 29 { jwin_button_proc, 42, 170, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
7437 29 { jwin_button_proc, 124, 170, 72, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Preview", NULL, NULL },
7438 29 { jwin_button_proc, 218, 170, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
7439 29 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
7440 29 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
7441 };
7442
7443 int32_t onScreenSaver()
7444 {
7445 scrsaver_dlg[0].dp2=lfont;
7446 int32_t oldcfgs[3];
7447 scrsaver_dlg[5].d1 = scrsaver_dlg[5].d2 = oldcfgs[0] = ss_after;
7448 scrsaver_dlg[6].d2 = oldcfgs[1] = ss_speed;
7449 scrsaver_dlg[7].d2 = oldcfgs[2] = ss_density;
7450
7451 large_dialog(scrsaver_dlg);
7452
7453 int32_t ret = do_zqdialog(scrsaver_dlg,-1);
7454
7455 if(ret == 8 || ret == 9)
7456 {
7457 ss_after = scrsaver_dlg[5].d1;
7458 ss_speed = scrsaver_dlg[6].d2;
7459 ss_density = scrsaver_dlg[7].d2;
7460 if(oldcfgs[0] != ss_after)
7461 zc_set_config(cfg_sect,"ss_after",ss_after);
7462 if(oldcfgs[1] != ss_speed)
7463 zc_set_config(cfg_sect,"ss_speed",ss_speed);
7464 if(oldcfgs[2] != ss_density)
7465 zc_set_config(cfg_sect,"ss_density",ss_density);
7466 }
7467
7468 if(ret == 9)
7469 // preview Screen Saver
7470 {
7471 clear_keybuf();
7472 scare_mouse();
7473 Matrix(ss_speed, ss_density, 30);
7474 system_pal();
7475 unscare_mouse();
7476 }
7477
7478 return D_O_K;
7479 }
7480
7481 /***** Menus *****/
7482
7483 static MENU game_menu[] =
7484 {
7485 { (char *)"&Continue\tESC", onContinue, NULL, 0, NULL },
7486 { (char *)"", NULL, NULL, 0, NULL },
7487 { (char *)"L&oad Quest...", onCustomGame, NULL, 0, NULL },
7488 { (char *)"&End Game\tF6", onTryQuitMenu, NULL, 0, NULL },
7489 { (char *)"", NULL, NULL, 0, NULL },
7490 #ifdef __EMSCRIPTEN__
7491 { (char *)"&Reset\tF7", onReset, NULL, 0, NULL },
7492 #elif defined(ALLEGRO_MACOSX)
7493 { (char *)"&Reset\tF7", onReset, NULL, 0, NULL },
7494 { (char *)"&Quit\tF8", onExit, NULL, 0, NULL },
7495 #else
7496 { (char *)"&Reset\tF9", onReset, NULL, 0, NULL },
7497 { (char *)"&Quit\tF10", onExit, NULL, 0, NULL },
7498 #endif
7499 { NULL, NULL, NULL, 0, NULL }
7500 };
7501
7502 static MENU title_menu[] =
7503 {
7504 { (char *)"&Original", onTitle_NES, NULL, 0, NULL },
7505 { (char *)"&Zelda Classic", onTitle_DX, NULL, 0, NULL },
7506 { (char *)"Zelda Classic &2.50", onTitle_25, NULL, 0, NULL },
7507 { NULL, NULL, NULL, 0, NULL }
7508 };
7509
7510 static MENU snapshot_format_menu[] =
7511 {
7512 { (char *)"&BMP", onSetSnapshotFormat, NULL, 0, NULL },
7513 { (char *)"&GIF", onSetSnapshotFormat, NULL, 0, NULL },
7514 { (char *)"&JPG", onSetSnapshotFormat, NULL, 0, NULL },
7515 { (char *)"&PNG", onSetSnapshotFormat, NULL, 0, NULL },
7516 { (char *)"PC&X", onSetSnapshotFormat, NULL, 0, NULL },
7517 { (char *)"&TGA", onSetSnapshotFormat, NULL, 0, NULL },
7518 { NULL, NULL, NULL, 0, NULL }
7519 };
7520
7521 static MENU controls_menu[] =
7522 {
7523 { (char *)"Key&board...", onKeyboard, NULL, 0, NULL },
7524 { (char *)"&Gamepad...", onGamepad, NULL, 0, NULL },
7525 { (char *)"&Cheat Keys...", onCheatKeys, NULL, 0, NULL },
7526 { NULL, NULL, NULL, 0, NULL }
7527 };
7528
7529 static MENU name_entry_mode_menu[] =
7530 {
7531 { (char *)"&Keyboard", onKeyboardEntry, NULL, 0, NULL },
7532 { (char *)"&Letter Grid", onLetterGridEntry, NULL, 0, NULL },
7533 { (char *)"&Extended Letter Grid", onExtLetterGridEntry, NULL, 0, NULL },
7534 { NULL, NULL, NULL, 0, NULL }
7535 };
7536
7537 static void set_controls_menu_active()
7538 {
7539
7540 }
7541
7542 static MENU window_menu[] =
7543 {
7544 { "Save Size Changes", onSaveDragResize, NULL, 0, NULL },
7545 { "Lock Aspect Ratio", onDragAspect, NULL, 0, NULL },
7546 { "Save Position Changes", onWinPosSave, NULL, 0, NULL },
7547 { NULL, NULL, NULL, 0, NULL }
7548 };
7549 static MENU options_menu[] =
7550 {
7551 { "&Title Screen", NULL, title_menu, 0, NULL },
7552 { "Name &Entry Mode", NULL, name_entry_mode_menu, 0, NULL },
7553 { "S&napshot Format", NULL, snapshot_format_menu, 0, NULL },
7554 { "&Window Settings", NULL, window_menu, 0, NULL },
7555 { "Epilepsy Flash Reduction", onEpilepsy, NULL, 0, NULL },
7556 { "Windows MIDI Patch", onMIDIPatch, NULL, 0, NULL },
7557 { NULL, NULL, NULL, 0, NULL }
7558 };
7559 static MENU settings_menu[] =
7560 {
7561 { "&Sound...", onSound, NULL, 0, NULL },
7562 { "C&ontrols", NULL, controls_menu, 0, NULL },
7563 { "", NULL, NULL, 0, NULL },
7564 { "Options", NULL, options_menu, 0, NULL },
7565 { "", NULL, NULL, 0, NULL },
7566 //
7567 { "&Cap FPS\tF1", onVsync, NULL, 0, NULL },
7568 { "Show &FPS\tF2", onShowFPS, NULL, 0, NULL },
7569 { "Click to Freeze", onClickToFreeze, NULL, 0, NULL },
7570 { "Cont. &Heart Beep", onHeartBeep, NULL, 0, NULL },
7571 { "Show Trans. &Layers", onTransLayers, NULL, 0, NULL },
7572 //
7573 { "Up+A+B To &Quit", onNESquit, NULL, 0, NULL },
7574 { "Volume &Keys", onVolKeys, NULL, 0, NULL },
7575 { "Sa&ve Indicator", onSaveIndicator, NULL, 0, NULL },
7576 { "", NULL, NULL, 0, NULL },
7577 { "Debu&g", onDebug, NULL, 0, NULL },
7578 //
7579 { NULL, NULL, NULL, 0, NULL }
7580 };
7581
7582
7583 static MENU misc_menu[] =
7584 {
7585 { (char *)"&About...", onAbout, NULL, 0, NULL },
7586 { (char *)"&Credits...", onCredits, NULL, 0, NULL },
7587 { (char *)"&Fullscreen", onFullscreenMenu, NULL, 0, NULL },
7588 { (char *)"&Video Mode...", onVidMode, NULL, 0, NULL },
7589 { (char *)"", NULL, NULL, 0, NULL },
7590 //5
7591 { (char *)"&Quest Info...", onQuest, NULL, 0, NULL },
7592 { (char *)"Quest &MIDI Info...", onMIDICredits, NULL, 0, NULL },
7593 { (char *)"Quest &Directory...", onQstPath, NULL, 0, NULL },
7594 { (char *)"", NULL, NULL, 0, NULL },
7595 { (char *)"Take &Snapshot\tF12", onSnapshot, NULL, 0, NULL },
7596 //10
7597 { (char *)"Sc&reen Saver...", onScreenSaver, NULL, 0, NULL },
7598 { (char *)"Save ZC Configuration", OnSaveZCConfig, NULL, 0, NULL },
7599 { (char *)"Show ZASM Debugger", onConsoleZASM, NULL, 0, NULL },
7600 { (char *)"Show ZScript Debugger", onConsoleZScript, NULL, 0, NULL },
7601 { (char *)"Clear Console on Qst Load", onClrConsoleOnLoad, NULL, 0, NULL },
7602 //15
7603 { (char *)"Clear Directory Cache", OnnClearQuestDir, NULL, 0, NULL },
7604 { (char *)"Modules", NULL, zcmodule_menu, 0, NULL },
7605 { NULL, NULL, NULL, 0, NULL }
7606 };
7607
7608 static MENU refill_menu[] =
7609 {
7610 { (char *)"&Life", onRefillLife, NULL, 0, NULL },
7611 { (char *)"&Magic", onRefillMagic, NULL, 0, NULL },
7612 { (char *)"&Bombs", onCheatBombs, NULL, 0, NULL },
7613 { (char *)"&Rupees", onCheatRupies, NULL, 0, NULL },
7614 { (char *)"&Arrows", onCheatArrows, NULL, 0, NULL },
7615 { NULL, NULL, NULL, 0, NULL }
7616 };
7617
7618 static MENU show_menu[] =
7619 {
7620 { (char *)"Combos", onShowLayer0, NULL, 0, NULL },
7621 { (char *)"Layer 1", onShowLayer1, NULL, 0, NULL },
7622 { (char *)"Layer 2", onShowLayer2, NULL, 0, NULL },
7623 { (char *)"Layer 3", onShowLayer3, NULL, 0, NULL },
7624 { (char *)"Layer 4", onShowLayer4, NULL, 0, NULL },
7625 { (char *)"Layer 5", onShowLayer5, NULL, 0, NULL },
7626 { (char *)"Layer 6", onShowLayer6, NULL, 0, NULL },
7627 { (char *)"Overhead Combos", onShowLayerO, NULL, 0, NULL },
7628 { (char *)"Push Blocks", onShowLayerP, NULL, 0, NULL },
7629 { (char *)"Freeform Combos", onShowLayerF, NULL, 0, NULL },
7630 { (char *)"Sprites", onShowLayerS, NULL, 0, NULL },
7631 { (char *)"", NULL, NULL, 0, NULL },
7632 { (char *)"Current FFC Scripts", onShowFFScripts, NULL, 0, NULL },
7633 { (char *)"", NULL, NULL, 0, NULL },
7634 { (char *)"Walkability", onShowLayerW, NULL, 0, NULL },
7635 { (char *)"Hitboxes", onShowHitboxes, NULL, 0, NULL },
7636 { (char *)"Effects", onShowLayerE, NULL, 0, NULL },
7637 { (char *)"Info Opacity", onShowInfoOpacity, NULL, 0, NULL },
7638 { NULL, NULL, NULL, 0, NULL }
7639 };
7640
7641 static MENU cheat_menu[] =
7642 {
7643 { (char *)"Set &Cheat", onCheat, NULL, 0, NULL },
7644 { (char *)"", NULL, NULL, 0, NULL },
7645 { (char *)"Re&fill", NULL, refill_menu, 0, NULL },
7646 { (char *)"", NULL, NULL, 0, NULL },
7647 { (char *)"&Invincible", onClock, NULL, 0, NULL },
7648 { (char *)"Ma&x Bombs...", onMaxBombs, NULL, 0, NULL },
7649 { (char *)"&Heart Containers...", onHeartC, NULL, 0, NULL },
7650 { (char *)"&Magic Containers...", onMagicC, NULL, 0, NULL },
7651 { (char *)"", NULL, NULL, 0, NULL },
7652 { (char *)"&Player Data...", onCheatConsole, NULL, 0, NULL },
7653 { (char *)"", NULL, NULL, 0, NULL },
7654 { (char *)"Walk Through &Walls", onNoWalls, NULL, 0, NULL },
7655 { (char *)"Player Ignores Side&view", onIgnoreSideview, NULL, 0, NULL },
7656 { (char *)"&Quick Movement", onGoFast, NULL, 0, NULL },
7657 { (char *)"&Kill All Enemies", onKillCheat, NULL, 0, NULL },
7658 { (char *)"Trigger &Secrets", onSecretsCheat, NULL, 0, NULL },
7659 { (char *)"Trigger Secrets Perm", onSecretsCheatPerm, NULL, 0, NULL },
7660 { (char *)"Show/Hide Layer", NULL, show_menu, 0, NULL },
7661 { (char *)"Toggle &Light", onLightSwitch, NULL, 0, NULL },
7662 { (char *)"&Goto Location...", onGoTo, NULL, 0, NULL },
7663 { NULL, NULL, NULL, 0, NULL }
7664 };
7665
7666 #if DEVLEVEL > 0
7667 int32_t devLogging();
7668 int32_t devDebug();
7669 int32_t devTimestmp();
7670 #if DEVLEVEL > 1
7671 int32_t setCheat();
7672 #endif //DEVLEVEL > 1
7673 enum
7674 {
7675 dv_log,
7676 // dv_dbg,
7677 dv_tmpstmp,
7678 #if DEVLEVEL > 1
7679 dv_nil,
7680 dv_setcheat,
7681 #endif //DEVLEVEL > 1
7682 dv_max
7683 };
7684 static MENU dev_menu[] =
7685 {
7686 { (char *)"&Force Error Log", devLogging, NULL, 0, NULL },
7687 // { (char *)"&Extra Debug Log", devDebug, NULL, 0, NULL },
7688 { (char *)"&Timestamp Log", devTimestmp, NULL, 0, NULL },
7689 #if DEVLEVEL > 1
7690 { (char *)"", NULL, NULL, 0, NULL },
7691 { (char *)"Set &Cheat", setCheat, NULL, 0, NULL },
7692 #endif //DEVLEVEL > 1
7693 { NULL, NULL, NULL, 0, NULL }
7694 };
7695 int32_t devLogging()
7696 {
7697 dev_logging = !dev_logging;
7698 dev_menu[dv_log].flags = dev_logging ? D_SELECTED : 0;
7699 return D_O_K;
7700 }
7701 // int32_t devDebug()
7702 // {
7703 // dev_debug = !dev_debug;
7704 // dev_menu[dv_dbg].flags = dev_debug ? D_SELECTED : 0;
7705 // return D_O_K;
7706 // }
7707 int32_t devTimestmp()
7708 {
7709 dev_timestmp = !dev_timestmp;
7710 dev_menu[dv_tmpstmp].flags = dev_timestmp ? D_SELECTED : 0;
7711 return D_O_K;
7712 }
7713 #if DEVLEVEL > 1
7714 int32_t setCheat()
7715 {
7716 cheat = (vbound(getnumber("Cheat Level",cheat), 0, 4));
7717 return D_O_K;
7718 }
7719 #endif //DEVLEVEL > 1
7720 #endif //DEVLEVEL > 0
7721
7722 MENU the_player_menu[] =
7723 {
7724 { (char *)"&Game", NULL, game_menu, 0, NULL },
7725 { (char *)"&Settings", NULL, settings_menu, 0, NULL },
7726 { (char *)"&Cheat", NULL, cheat_menu, 0, NULL },
7727 { (char *)"Replay", NULL, replay_menu, 0, NULL },
7728 { (char *)"&ZC", NULL, misc_menu, 0, NULL },
7729 #if DEVLEVEL > 0
7730 { (char *)"&Dev", NULL, dev_menu, 0, NULL },
7731 #endif
7732 { NULL, NULL, NULL, 0, NULL }
7733 };
7734
7735 int32_t onMIDIPatch()
7736 {
7737 if(jwin_alert3(
7738 "Toggle Windows MIDI Fix",
7739 "This action will change whether ZC Player auto-restarts a MIDI at its",
7740 "last index if you move ZC Player out of focus, then back into focus.",
7741 "Proceed?",
7742 "&Yes",
7743 "&No",
7744 NULL,
7745 'y',
7746 'n',
7747 0,
7748 lfont) == 1)
7749 {
7750 midi_patch_fix = midi_patch_fix ? 0 : 1;
7751 zc_set_config("zeldadx","midi_patch_fix",midi_patch_fix);
7752 }
7753 options_menu[5].flags =(midi_patch_fix)?D_SELECTED:0;
7754 return D_O_K;
7755 }
7756
7757 int32_t onKeyboardEntry()
7758 {
7759 NameEntryMode=0;
7760 zc_set_config(cfg_sect,"name_entry_mode",NameEntryMode);
7761 return D_O_K;
7762 }
7763
7764 int32_t onLetterGridEntry()
7765 {
7766 NameEntryMode=1;
7767 zc_set_config(cfg_sect,"name_entry_mode",NameEntryMode);
7768 return D_O_K;
7769 }
7770
7771 int32_t onExtLetterGridEntry()
7772 {
7773 NameEntryMode=2;
7774 zc_set_config(cfg_sect,"name_entry_mode",NameEntryMode);
7775 return D_O_K;
7776 }
7777
7778 static BITMAP* truescreen;
7779 int32_t onFullscreenMenu()
7780 {
7781 BITMAP* os = screen==truescreen? nullptr : screen;
7782 screen = truescreen;
7783 if(onFullscreen()==D_REDRAW)
7784 truescreen = screen;
7785 if(os) screen = os;
7786 misc_menu[2].flags =(isFullScreen()==1)?D_SELECTED:0;
7787 return D_O_K;
7788 }
7789
7790 29 void fix_menu()
7791 {
7792
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
29 if(!debug_enabled)
7793 29 settings_menu[13].text = NULL;
7794 29 }
7795
7796 static DIALOG system_dlg[] =
7797 {
7798 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
7799 { jwin_menu_proc, 0, 0, 0, 0, 0, 0, 0, D_USER, 0, 0, (void *) the_player_menu, NULL, NULL },
7800 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F1, 0, (void *) onVsync, NULL, NULL },
7801 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F2, 0, (void *) onShowFPS, NULL, NULL },
7802 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F6, 0, (void *) onTryQuitMenu, NULL, NULL },
7803 #ifndef ALLEGRO_MACOSX
7804 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F9, 0, (void *) onReset, NULL, NULL },
7805 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F10, 0, (void *) onExit, NULL, NULL },
7806 #else
7807 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F7, 0, (void *) onReset, NULL, NULL },
7808 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F8, 0, (void *) onExit, NULL, NULL },
7809 #endif
7810 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F12, 0, (void *) onSnapshot, NULL, NULL },
7811 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_TAB, 0, (void *) onDebug, NULL, NULL },
7812 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
7813 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
7814 };
7815
7816 void reset_snapshot_format_menu()
7817 {
7818 for(int32_t i=0; i<ssfmtMAX; ++i)
7819 {
7820 snapshot_format_menu[i].flags=0;
7821 }
7822 }
7823
7824 int32_t onSetSnapshotFormat()
7825 {
7826 switch(active_menu->text[1])
7827 {
7828 case 'B': //"&BMP"
7829 SnapshotFormat=0;
7830 break;
7831
7832 case 'G': //"&GIF"
7833 SnapshotFormat=1;
7834 break;
7835
7836 case 'J': //"&JPG"
7837 SnapshotFormat=2;
7838 break;
7839
7840 case 'P': //"&PNG"
7841 SnapshotFormat=3;
7842 break;
7843
7844 case 'C': //"PC&X"
7845 SnapshotFormat=4;
7846 break;
7847
7848 case 'T': //"&TGA"
7849 SnapshotFormat=5;
7850 break;
7851
7852 case 'L': //"&LBM"
7853 SnapshotFormat=6;
7854 break;
7855 }
7856 zc_set_config("zeldadx", "snapshot_format", SnapshotFormat);
7857
7858 snapshot_format_menu[SnapshotFormat].flags=D_SELECTED;
7859 return D_O_K;
7860 }
7861
7862
7863 43 void color_layer(RGB *src,RGB *dest,char r,char g,char b,char pos,int32_t from,int32_t to)
7864 {
7865 PALETTE tmp;
7866
7867
2/2
✓ Branch 0 taken 11008 times.
✓ Branch 1 taken 43 times.
11051 for(int32_t i=0; i<256; i++)
7868 {
7869 11008 tmp[i].r=r;
7870 11008 tmp[i].g=g;
7871 11008 tmp[i].b=b;
7872 11008 }
7873
7874 43 fade_interpolate(src,tmp,dest,pos,from,to);
7875 43 }
7876
7877 43 void system_pal()
7878 {
7879 43 is_sys_pal = true;
7880 static PALETTE pal;
7881 43 copy_pal((RGB*)datafile[PAL_GUI].dat, pal);
7882
7883 // set up the grayscale palette
7884
2/2
✓ Branch 0 taken 2752 times.
✓ Branch 1 taken 43 times.
2795 for(int32_t i=128; i<192; i++)
7885 {
7886 2752 pal[i].r = i-128;
7887 2752 pal[i].g = i-128;
7888 2752 pal[i].b = i-128;
7889 2752 }
7890 43 load_colorset(gui_colorset, pal);
7891
7892 43 color_layer(pal, pal, 24,16,16, 28, 128,191);
7893
7894
2/2
✓ Branch 0 taken 5504 times.
✓ Branch 1 taken 43 times.
5547 for(int32_t i=0; i<256; i+=2)
7895 {
7896 5504 int32_t v = (i>>3)+2;
7897 5504 int32_t c = (i>>3)+192;
7898 5504 pal[c] = _RGB(v,v,v+(v>>1));
7899 /*
7900 if(i<240)
7901 {
7902 _allegro_hline(tmp_scr,0,i,319,c);
7903 _allegro_hline(tmp_scr,0,i+1,319,c);
7904 }
7905 */
7906 5504 }
7907
7908 // draw the vertical screen gradient
7909
2/2
✓ Branch 0 taken 10320 times.
✓ Branch 1 taken 43 times.
10363 for(int32_t i=0; i<240; ++i)
7910 {
7911 10320 _allegro_hline(tmp_scr,0,i,319,192+(i*31/239));
7912 10320 }
7913
7914 /*
7915 palrstart= 10*63/255; palrend=166*63/255;
7916 palgstart= 36*63/255; palgend=202*63/255;
7917 palbstart=106*63/255; palbend=240*63/255;
7918 paldivs=32;
7919 for(int32_t i=0; i<paldivs; i++)
7920 {
7921 pal[223-paldivs+1+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
7922 pal[223-paldivs+1+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
7923 pal[223-paldivs+1+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
7924 }
7925 */
7926 43 BITMAP *panorama = create_bitmap_ex(8,256,224);
7927 int32_t ts_height, ts_start;
7928
7929
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 43 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
43 if(tmpscr->flags3&fNOSUBSCR && !(tmpscr->flags3&fNOSUBSCROFFSET))
7930 {
7931 clear_to_color(panorama,0);
7932 blit(framebuf,panorama,0,playing_field_offset,0,28,256,224-passive_subscreen_height);
7933 ts_height=224-passive_subscreen_height;
7934 ts_start=28;
7935 }
7936 else
7937 {
7938 43 blit(framebuf,panorama,0,0,0,0,256,224);
7939 43 ts_height=224;
7940 43 ts_start=0;
7941 }
7942
7943 // gray scale the current frame
7944
2/2
✓ Branch 0 taken 9632 times.
✓ Branch 1 taken 43 times.
9675 for(int32_t y=0; y<ts_height; y++)
7945 {
7946
2/2
✓ Branch 0 taken 2465792 times.
✓ Branch 1 taken 9632 times.
2475424 for(int32_t x=0; x<256; x++)
7947 {
7948 2465792 int32_t c = panorama->line[y+ts_start][x];
7949
2/2
✓ Branch 0 taken 2459902 times.
✓ Branch 1 taken 5890 times.
2465792 int32_t gray = zc_min((RAMpal[c].r*42 + RAMpal[c].g*75 + RAMpal[c].b*14) >> 7, 63);
7950 2465792 tmp_scr->line[y+8+ts_start][x+32] = gray+128;
7951 2465792 }
7952 9632 }
7953
7954 43 destroy_bitmap(panorama);
7955
7956 // display everything
7957 43 vsync();
7958 43 hw_palette = &pal;
7959 43 update_hw_pal = true;
7960
7961 // sys_pal = pal;
7962 43 memcpy(sys_pal,pal,sizeof(pal));
7963 43 }
7964
7965 void system_pal2()
7966 {
7967 is_sys_pal = true;
7968 static PALETTE RAMpal2;
7969 copy_pal((RGB*)datafile[PAL_GUI].dat, RAMpal2);
7970
7971 /* Windows 2000 colors
7972 RAMpal2[dvc(1)] = _RGB( 0*63/255, 0*63/255, 0*63/255);
7973 RAMpal2[dvc(2)] = _RGB( 66*63/255, 65*63/255, 66*63/255);
7974 RAMpal2[dvc(3)] = _RGB(132*63/255, 130*63/255, 132*63/255);
7975 RAMpal2[dvc(4)] = _RGB(212*63/255, 208*63/255, 200*63/255);
7976 RAMpal2[dvc(5)] = _RGB(255*63/255, 255*63/255, 255*63/255);
7977 RAMpal2[dvc(6)] = _RGB(255*63/255, 255*63/255, 225*63/255);
7978 RAMpal2[dvc(7)] = _RGB(255*63/255, 225*63/255, 160*63/255);
7979 RAMpal2[dvc(8)] = _RGB( 0*63/255, 0*63/255, 80*63/255);
7980
7981 byte palrstart= 10*63/255, palrend=166*63/255,
7982 palgstart= 36*63/255, palgend=202*63/255,
7983 palbstart=106*63/255, palbend=240*63/255,
7984 paldivs=7;
7985 for(int32_t i=0; i<paldivs; i++)
7986 {
7987 RAMpal2[dvc(15-paldivs+1)+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
7988 RAMpal2[dvc(15-paldivs+1)+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
7989 RAMpal2[dvc(15-paldivs+1)+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
7990 }
7991 */
7992
7993 /* Windows 98 colors
7994 RAMpal2[dvc(1)] = _RGB( 0*63/255, 0*63/255, 0*63/255);
7995 RAMpal2[dvc(2)] = _RGB(128*63/255, 128*63/255, 128*63/255);
7996 RAMpal2[dvc(3)] = _RGB(192*63/255, 192*63/255, 192*63/255);
7997 RAMpal2[dvc(4)] = _RGB(223*63/255, 223*63/255, 223*63/255);
7998 RAMpal2[dvc(5)] = _RGB(255*63/255, 255*63/255, 255*63/255);
7999 RAMpal2[dvc(6)] = _RGB(255*63/255, 255*63/255, 225*63/255);
8000 RAMpal2[dvc(7)] = _RGB(255*63/255, 225*63/255, 160*63/255);
8001 RAMpal2[dvc(8)] = _RGB( 0*63/255, 0*63/255, 80*63/255);
8002
8003 byte palrstart= 0*63/255, palrend=166*63/255,
8004 palgstart= 0*63/255, palgend=202*63/255,
8005 palbstart=128*63/255, palbend=240*63/255,
8006 paldivs=7;
8007 for(int32_t i=0; i<paldivs; i++)
8008 {
8009 RAMpal2[dvc(15-paldivs+1)+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8010 RAMpal2[dvc(15-paldivs+1)+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8011 RAMpal2[dvc(15-paldivs+1)+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8012 }
8013 */
8014
8015 /* Windows 99 colors
8016 RAMpal2[dvc(1)] = _RGB( 0*63/255, 0*63/255, 0*63/255);
8017 RAMpal2[dvc(2)] = _RGB( 64*63/255, 64*63/255, 64*63/255);
8018 RAMpal2[dvc(3)] = _RGB(128*63/255, 128*63/255, 128*63/255);
8019 RAMpal2[dvc(4)] = _RGB(192*63/255, 192*63/255, 192*63/255);
8020 RAMpal2[dvc(5)] = _RGB(223*63/255, 223*63/255, 223*63/255);
8021 RAMpal2[dvc(6)] = _RGB(255*63/255, 255*63/255, 255*63/255);
8022 RAMpal2[dvc(7)] = _RGB(255*63/255, 255*63/255, 225*63/255);
8023 RAMpal2[dvc(8)] = _RGB(255*63/255, 225*63/255, 160*63/255);
8024 RAMpal2[dvc(9)] = _RGB( 0*63/255, 0*63/255, 80*63/255);
8025
8026 byte palrstart= 0*63/255, palrend=166*63/255,
8027 palgstart= 0*63/255, palgend=202*63/255,
8028
8029 palbstart=128*63/255, palbend=240*63/255,
8030 paldivs=6;
8031 for(int32_t i=0; i<paldivs; i++)
8032 {
8033 RAMpal2[dvc(15-paldivs+1)+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8034 RAMpal2[dvc(15-paldivs+1)+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8035 RAMpal2[dvc(15-paldivs+1)+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8036 }
8037 */
8038
8039
8040
8041 RAMpal2[dvc(1)] = _RGB(0*63/255, 0*63/255, 0*63/255);
8042 RAMpal2[dvc(2)] = _RGB(64*63/255, 64*63/255, 64*63/255);
8043 RAMpal2[dvc(3)] = _RGB(128*63/255, 128*63/255, 128*63/255);
8044 RAMpal2[dvc(4)] = _RGB(192*63/255, 192*63/255, 192*63/255);
8045 RAMpal2[dvc(5)] = _RGB(223*63/255, 223*63/255, 223*63/255);
8046 RAMpal2[dvc(6)] = _RGB(255*63/255, 255*63/255, 255*63/255);
8047 RAMpal2[dvc(7)] = _RGB(255*63/255, 255*63/255, 225*63/255);
8048 RAMpal2[dvc(8)] = _RGB(255*63/255, 225*63/255, 160*63/255);
8049 RAMpal2[dvc(9)] = _RGB(0*63/255, 0*63/255, 80*63/255);
8050
8051 byte palrstart= 0*63/255, palrend=166*63/255,
8052 palgstart= 0*63/255, palgend=202*63/255,
8053 palbstart=128*63/255, palbend=240*63/255,
8054 paldivs=6;
8055
8056 for(int32_t i=0; i<paldivs; i++)
8057 {
8058 RAMpal2[dvc(15-paldivs+1)+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8059 RAMpal2[dvc(15-paldivs+1)+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8060 RAMpal2[dvc(15-paldivs+1)+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8061 }
8062
8063 gui_bg_color=jwin_pal[jcBOX];
8064 gui_fg_color=jwin_pal[jcBOXFG];
8065
8066 jwin_set_colors(jwin_pal);
8067
8068
8069 // set up the new palette
8070 for(int32_t i=128; i<192; i++)
8071 {
8072 RAMpal2[i].r = i-128;
8073 RAMpal2[i].g = i-128;
8074 RAMpal2[i].b = i-128;
8075 }
8076
8077 /*
8078 for(int32_t i=0; i<64; i++)
8079 {
8080 RAMpal2[128+i] = _RGB(i,i,i)1));
8081 }
8082 */
8083
8084 /*
8085
8086 pal[vc(1)] = _RGB(0x00,0x00,0x14);
8087 pal[vc(4)] = _RGB(0x36,0x36,0x36);
8088 pal[vc(6)] = _RGB(0x10,0x10,0x10);
8089 pal[vc(7)] = _RGB(0x20,0x20,0x20);
8090 pal[vc(9)] = _RGB(0x20,0x20,0x24);
8091 pal[vc(11)] = _RGB(0x30,0x30,0x30);
8092 pal[vc(14)] = _RGB(0x3F,0x38,0x28);
8093
8094 gui_fg_color=vc(14);
8095 gui_bg_color=vc(1);
8096
8097 jwin_set_colors(jwin_pal);
8098 */
8099
8100 // color_layer(RAMpal2, RAMpal2, 24,16,16, 28, 128,191);
8101
8102 // set up the colors for the vertical screen gradient
8103 for(int32_t i=0; i<256; i+=2)
8104 {
8105 int32_t v = (i>>3)+2;
8106 int32_t c = (i>>3)+192;
8107 RAMpal2[c] = _RGB(v,v,v+(v>>1));
8108
8109 /*
8110 if(i<240)
8111 {
8112 _allegro_hline(tmp_scr,0,i,319,c);
8113 _allegro_hline(tmp_scr,0,i+1,319,c);
8114 }
8115 */
8116 }
8117
8118 // hw_palette = &RAMpal;
8119 // update_hw_pal = true;
8120
8121 for(int32_t i=0; i<240; ++i)
8122 {
8123 _allegro_hline(tmp_scr,0,i,319,192+(i*31/239));
8124 }
8125
8126 /*
8127 byte palrstart= 10*63/255, palrend=166*63/255,
8128 palgstart= 36*63/255, palgend=202*63/255,
8129 palbstart=106*63/255, palbend=240*63/255,
8130 paldivs=32;
8131 for(int32_t i=0; i<paldivs; i++)
8132 {
8133 pal[223-paldivs+1+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8134 pal[223-paldivs+1+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8135 pal[223-paldivs+1+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8136 }
8137 */
8138 BITMAP *panorama = create_bitmap_ex(8,256,224);
8139 int32_t ts_height, ts_start;
8140
8141 if(tmpscr->flags3&fNOSUBSCR && !(tmpscr->flags3&fNOSUBSCROFFSET))
8142 {
8143 clear_to_color(panorama,0);
8144 blit(framebuf,panorama,0,playing_field_offset,0,28,256,224-passive_subscreen_height);
8145 ts_height=224-passive_subscreen_height;
8146 ts_start=28;
8147 }
8148 else
8149 {
8150 blit(framebuf,panorama,0,0,0,0,256,224);
8151 ts_height=224;
8152 ts_start=0;
8153 }
8154
8155 // gray scale the current frame
8156 for(int32_t y=0; y<ts_height; y++)
8157 {
8158 for(int32_t x=0; x<256; x++)
8159 {
8160 int32_t c = panorama->line[y+ts_start][x];
8161 int32_t gray = zc_min((RAMpal2[c].r*42 + RAMpal2[c].g*75 + RAMpal2[c].b*14) >> 7, 63);
8162 tmp_scr->line[y+8+ts_start][x+32] = gray+128;
8163 }
8164 }
8165
8166 destroy_bitmap(panorama);
8167
8168 // display everything
8169 vsync();
8170 hw_palette = &RAMpal2;
8171 update_hw_pal = true;
8172
8173 blit(tmp_scr,screen,0,0,scrx,scry,320,240);
8174
8175 // sys_pal = pal;
8176 memcpy(sys_pal,RAMpal2,sizeof(RAMpal2));
8177 }
8178
8179 static uint32_t entered_sys_pal = 0;
8180 14 void enter_sys_pal()
8181 {
8182
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(is_sys_pal)
8183 {
8184 if(entered_sys_pal)
8185 ++entered_sys_pal;
8186 return;
8187 }
8188 14 system_pal();
8189 14 ++entered_sys_pal;
8190 14 }
8191 14 void exit_sys_pal()
8192 {
8193
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(entered_sys_pal)
8194 {
8195
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if(!--entered_sys_pal)
8196 {
8197 14 game_pal();
8198 14 }
8199 14 }
8200 14 }
8201
8202 void switch_out_callback()
8203 {
8204 if (pause_in_background)
8205 {
8206 callback_switchin = 3;
8207 return;
8208 }
8209
8210 #ifdef _WIN32
8211 if(midi_patch_fix==0 || currmidi==-1)
8212 return;
8213
8214
8215 paused_midi_pos = midi_pos;
8216 zc_stop_midi();
8217 midi_paused=true;
8218 midi_suspended = midissuspHALTED;
8219 #endif
8220 }
8221
8222 void switch_in_callback()
8223 {
8224 if(pause_in_background)
8225 {
8226 return;
8227 }
8228
8229 #ifdef _WIN32
8230 if(midi_patch_fix==0 || currmidi==-1)
8231 return;
8232
8233 else
8234 {
8235 callback_switchin = 1;
8236 midi_suspended = midissuspRESUME;
8237 }
8238 #endif
8239 }
8240
8241 257 void game_pal()
8242 {
8243 257 is_sys_pal = false;
8244 257 entered_sys_pal = 0;
8245 257 clear_to_color(screen,BLACK);
8246 257 hw_palette = &RAMpal;
8247 257 update_hw_pal = true;
8248 257 }
8249
8250 static char bar_str[] = "";
8251
8252 14 void music_pause()
8253 {
8254 //al_pause_duh(tmplayer);
8255 14 zcmusic_pause(zcmusic, ZCM_PAUSE);
8256 14 zc_midi_pause();
8257 14 midi_paused=true;
8258 14 }
8259
8260 void music_resume()
8261 {
8262 //al_resume_duh(tmplayer);
8263 zcmusic_pause(zcmusic, ZCM_RESUME);
8264 zc_midi_resume();
8265 midi_paused=false;
8266 }
8267
8268 5320 void music_stop()
8269 {
8270 //al_stop_duh(tmplayer);
8271 //unload_duh(tmusic);
8272 //tmusic=NULL;
8273 //tmplayer=NULL;
8274 5320 zcmusic_stop(zcmusic);
8275 5320 zcmusic_unload_file(zcmusic);
8276 5320 zc_stop_midi();
8277 5320 midi_paused=false;
8278 5320 currmidi=-1;
8279 5320 }
8280
8281 void System()
8282 {
8283 mouse_down=gui_mouse_b();
8284 music_pause();
8285 pause_all_sfx();
8286 MenuOpen = true;
8287 system_pal();
8288 // FONT *oldfont=font;
8289 // font=tfont;
8290
8291 misc_menu[2].flags =(isFullScreen()==1)?D_SELECTED:0;
8292 misc_menu[3].flags =(isFullScreen()==1)?D_DISABLED:0;
8293
8294 game_menu[2].flags = getsaveslot() > -1 ? 0 : D_DISABLED;
8295 #if DEVLEVEL > 1
8296 dev_menu[dv_setcheat].flags = Playing ? 0 : D_DISABLED;
8297 #endif
8298 game_menu[3].flags =
8299 misc_menu[5].flags = Playing ? 0 : D_DISABLED;
8300 misc_menu[7].flags = !Playing ? 0 : D_DISABLED;
8301 clear_keybuf();
8302 show_mouse(screen);
8303 truescreen = screen;
8304
8305 DIALOG_PLAYER *p;
8306
8307 ALLEGRO_STATE old_state;
8308 al_store_state(&old_state, ALLEGRO_STATE_TARGET_BITMAP);
8309 al_set_target_bitmap(rti_menu.bitmap);
8310
8311 system_dlg[0].dp2 = get_zc_font_a5(font_dsphantompfont);
8312 p = init_dialog(system_dlg,-1);
8313 // drop the menu on startup if menu button pressed
8314 if(joybtn(Mbtn)||zc_getrawkey(KEY_ESC))
8315 simulate_keypress(KEY_G << 8);
8316
8317 do
8318 {
8319 if(close_button_quit)
8320 {
8321 close_button_quit = false;
8322 f_Quit(qEXIT);
8323 if(Quit) break;
8324 }
8325 rest(17);
8326
8327 if(mouse_down && !gui_mouse_b())
8328 mouse_down=0;
8329
8330 title_menu[0].flags = (title_version==0) ? D_SELECTED : 0;
8331 title_menu[1].flags = (title_version==1) ? D_SELECTED : 0;
8332 title_menu[2].flags = (title_version==2) ? D_SELECTED : 0;
8333
8334 settings_menu[1].flags = replay_is_replaying() ? D_DISABLED : 0;
8335 settings_menu[5].flags = Throttlefps?D_SELECTED:0;
8336 settings_menu[6].flags = ShowFPS?D_SELECTED:0;
8337 settings_menu[7].flags = ClickToFreeze?D_SELECTED:0;
8338 settings_menu[9].flags = TransLayers?D_SELECTED:0;
8339 settings_menu[10].flags = NESquit?D_SELECTED:0;
8340 settings_menu[11].flags = volkeys?D_SELECTED:0;
8341
8342 window_menu[0].flags = SaveDragResize?D_SELECTED:0;
8343 window_menu[1].flags = DragAspect?D_SELECTED:0;
8344 window_menu[2].flags = SaveWinPos?D_SELECTED:0;
8345
8346 options_menu[4].flags = (epilepsyFlashReduction) ? D_SELECTED : 0;
8347 options_menu[5].flags = (midi_patch_fix)?D_SELECTED:0;
8348
8349 name_entry_mode_menu[0].flags = (NameEntryMode==0)?D_SELECTED:0;
8350 name_entry_mode_menu[1].flags = (NameEntryMode==1)?D_SELECTED:0;
8351 name_entry_mode_menu[2].flags = (NameEntryMode==2)?D_SELECTED:0;
8352
8353 misc_menu[12].flags =(zasm_debugger)?D_SELECTED:0;
8354 misc_menu[13].flags =(zscript_debugger)?D_SELECTED:0;
8355 misc_menu[14].flags =(clearConsoleOnLoad)?D_SELECTED:0;
8356 bool nocheat = (replay_is_replaying() || !Playing
8357 || (!zcheats.flags && !get_debug() && DEVLEVEL < 2 && !zqtesting_mode));
8358 the_player_menu[2].flags = nocheat ? D_DISABLED : 0;
8359 cheat_menu[0].flags = 0;
8360 refill_menu[4].flags = get_bit(quest_rules, qr_TRUEARROWS) ? 0 : D_DISABLED;
8361 cheat_menu[1].text = (cheat >= 1) || get_debug() ? bar_str : NULL;
8362 cheat_menu[3].text = (cheat >= 2) || get_debug() ? bar_str : NULL;
8363 cheat_menu[8].text = (cheat >= 3) || get_debug() ? bar_str : NULL;
8364 cheat_menu[10].text = (cheat >= 4) || get_debug() ? bar_str : NULL;
8365 cheat_menu[4].flags = getClock() ? D_SELECTED : 0;
8366 cheat_menu[11].flags = toogam ? D_SELECTED : 0;
8367 cheat_menu[12].flags = ignoreSideview ? D_SELECTED : 0;
8368 cheat_menu[13].flags = gofast ? D_SELECTED : 0;
8369
8370 show_menu[0].flags = show_layer_0 ? D_SELECTED : 0;
8371 show_menu[1].flags = show_layer_1 ? D_SELECTED : 0;
8372 show_menu[2].flags = show_layer_2 ? D_SELECTED : 0;
8373 show_menu[3].flags = show_layer_3 ? D_SELECTED : 0;
8374 show_menu[4].flags = show_layer_4 ? D_SELECTED : 0;
8375 show_menu[5].flags = show_layer_5 ? D_SELECTED : 0;
8376 show_menu[6].flags = show_layer_6 ? D_SELECTED : 0;
8377 show_menu[7].flags = show_layer_over ? D_SELECTED : 0;
8378 show_menu[8].flags = show_layer_push ? D_SELECTED : 0;
8379 show_menu[9].flags = show_sprites ? D_SELECTED : 0;
8380 show_menu[10].flags = show_ffcs ? D_SELECTED : 0;
8381 show_menu[12].flags = show_walkflags ? D_SELECTED : 0;
8382 show_menu[13].flags = show_ff_scripts ? D_SELECTED : 0;
8383 show_menu[14].flags = show_hitboxes ? D_SELECTED : 0;
8384 show_menu[15].flags = show_effectflags ? D_SELECTED : 0;
8385
8386 settings_menu[8].flags = heart_beep ? D_SELECTED : 0;
8387 settings_menu[12].flags = use_save_indicator ? D_SELECTED : 0;
8388
8389 replay_menu[0].text = zc_get_config("zeldadx", "replay_new_saves", false) ?
8390 (char *)"Disable recording new saves" :
8391 (char *)"Enable recording new saves";
8392 replay_menu[1].flags = replay_is_active() ? 0 : D_DISABLED;
8393 replay_menu[1].text = replay_get_mode() == ReplayMode::Record ?
8394 (char *)"Stop recording" :
8395 (char *)"Stop replaying";
8396 replay_menu[5].flags = replay_get_mode() == ReplayMode::Record ? 0 : D_DISABLED;
8397 replay_menu[6].text = replay_is_snapshot_all_frames() ?
8398 (char *)"Disable snapshot all frames" :
8399 (char *)"Enable snapshot all frames";
8400
8401 reset_snapshot_format_menu();
8402 snapshot_format_menu[SnapshotFormat].flags = D_SELECTED;
8403
8404 if(debug_enabled)
8405 {
8406 settings_menu[14].flags = get_debug() ? D_SELECTED : 0;
8407 }
8408
8409 if(gui_mouse_b() && !mouse_down)
8410 break;
8411
8412 // press menu to drop the menu
8413 if(rMbtn())
8414 simulate_keypress(KEY_G << 8);
8415
8416 if(input_idle(true) > after_time())
8417 // run Screeen Saver
8418 {
8419 // Screen saver enabled for now.
8420 clear_keybuf();
8421 scare_mouse();
8422 Matrix(ss_speed, ss_density, 0);
8423 system_pal();
8424 unscare_mouse();
8425 broadcast_dialog_message(MSG_DRAW, 0);
8426 }
8427
8428 update_hw_screen();
8429 }
8430 while(update_dialog(p));
8431
8432 al_restore_state(&old_state);
8433 screen = truescreen;
8434 // font=oldfont;
8435 mouse_down=gui_mouse_b();
8436 shutdown_dialog(p);
8437 show_mouse(NULL);
8438 MenuOpen = false;
8439 if(Quit)
8440 {
8441 kill_sfx();
8442 music_stop();
8443 update_hw_screen();
8444 }
8445 else
8446 {
8447 game_pal();
8448 music_resume();
8449 resume_all_sfx();
8450
8451 if(rc)
8452 ringcolor(false);
8453 }
8454
8455 eat_buttons();
8456
8457 rc=false;
8458 clear_keybuf();
8459 // text_mode(0);
8460 }
8461
8462 29 void fix_dialogs()
8463 {
8464 29 jwin_center_dialog(about_dlg);
8465 29 jwin_center_dialog(gamepad_dlg);
8466 29 jwin_center_dialog(credits_dlg);
8467 29 jwin_center_dialog(gamemode_dlg);
8468 29 jwin_center_dialog(goto_dlg);
8469 29 jwin_center_dialog(keyboard_control_dlg);
8470 29 jwin_center_dialog(midi_dlg);
8471 29 jwin_center_dialog(quest_dlg);
8472 29 jwin_center_dialog(scrsaver_dlg);
8473 29 jwin_center_dialog(sound_dlg);
8474 29 jwin_center_dialog(triforce_dlg);
8475
8476 // digi_dp[1] += scrx;
8477 // digi_dp[2] += scry;
8478 // midi_dp[1] += scrx;
8479 // midi_dp[2] += scry;
8480 // pan_dp[1] += scrx;
8481 // pan_dp[2] += scry;
8482 // emus_dp[1] += scrx;
8483 // emus_dp[2] += scry;
8484 // buf_dp[1] += scrx;
8485 // buf_dp[2] += scry;
8486 // sfx_dp[1] += scrx;
8487 // sfx_dp[2] += scry;
8488 29 }
8489
8490 /*****************************/
8491 /**** Custom Sound System ****/
8492 /*****************************/
8493
8494 2295 INLINE int32_t mixvol(int32_t v1,int32_t v2)
8495 {
8496
3/4
✓ Branch 0 taken 2061 times.
✓ Branch 1 taken 234 times.
✓ Branch 2 taken 2295 times.
✗ Branch 3 not taken.
2295 return (zc_min(v1,255)*zc_min(v2,255)) >> 8;
8497 }
8498
8499 // Run an NSF, or a MIDI if the NSF is missing somehow.
8500 83 bool try_zcmusic(char *filename, int32_t track, int32_t midi)
8501 {
8502 83 ZCMUSIC *newzcmusic = zcmusic_load_for_quest(filename, qstpath);
8503
8504 // Found it
8505
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 35 times.
83 if(newzcmusic!=NULL)
8506 {
8507 48 zcmusic_stop(zcmusic);
8508 48 zcmusic_unload_file(zcmusic);
8509 48 zc_stop_midi();
8510
8511 48 zcmusic=newzcmusic;
8512 48 zcmusic_play(zcmusic, emusic_volume);
8513
8514
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if(track>0)
8515 48 zcmusic_change_track(zcmusic,track);
8516
8517 48 return true;
8518 }
8519
8520 // Not found, play MIDI - unless this was called by a script (yay, magic numbers)
8521
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 else if(midi>-1000)
8522 jukebox(midi);
8523
8524 35 return false;
8525 83 }
8526
8527 bool try_zcmusic_ex(char *filename, int32_t track, int32_t midi)
8528 {
8529 ZCMUSIC *newzcmusic = zcmusic_load_for_quest(filename, qstpath);
8530 // Found it
8531 if(newzcmusic!=NULL)
8532 {
8533 zcmusic_stop(zcmusic);
8534 zcmusic_unload_file(zcmusic);
8535 zc_stop_midi();
8536
8537 zcmusic=newzcmusic;
8538 zcmusic_play(zcmusic, emusic_volume);
8539
8540 if(track>0)
8541 zcmusic_change_track(zcmusic,track);
8542
8543 return true;
8544 }
8545
8546 // Not found, play MIDI - unless this was called by a script (yay, magic numbers)
8547 else if(midi>-1000)
8548 jukebox(midi);
8549
8550 return false;
8551 }
8552
8553 int32_t get_zcmusicpos()
8554 {
8555 int32_t debugtracething = zcmusic_get_curpos(zcmusic);
8556 return debugtracething;
8557 return 0;
8558 }
8559
8560 void set_zcmusicpos(int32_t position)
8561 {
8562 zcmusic_set_curpos(zcmusic, position);
8563 }
8564
8565 void set_zcmusicspeed(int32_t speed)
8566 {
8567 int32_t newspeed = vbound(speed, 0, 10000);
8568 zcmusic_set_speed(zcmusic, newspeed);
8569 }
8570
8571 1133 void jukebox(int32_t index,int32_t loop)
8572 {
8573 1133 music_stop();
8574
8575
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1133 times.
1133 if(index<0) index=MAXMIDIS-1;
8576
8577
1/2
✓ Branch 0 taken 1133 times.
✗ Branch 1 not taken.
1133 if(index>=MAXMIDIS) index=0;
8578
8579 1133 music_stop();
8580
8581 // Allegro's DIGMID driver (the one normally used on on Linux) gets
8582 // stuck notes when a song stops. This fixes it.
8583
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1133 times.
1133 if(strcmp(midi_driver->name, "DIGMID")==0)
8584 zc_set_volume(0, 0);
8585
8586 1133 zc_set_volume(-1, mixvol(tunes[index].volume,midi_volume>>1));
8587 1133 zc_play_midi((MIDI*)tunes[index].data,loop);
8588
8589
2/2
✓ Branch 0 taken 756 times.
✓ Branch 1 taken 377 times.
1133 if(tunes[index].start>0)
8590 377 zc_midi_seek(tunes[index].start);
8591
8592 1133 midi_loop_start = tunes[index].loop_start;
8593 1133 midi_loop_end = tunes[index].loop_end;
8594
8595 1133 currmidi=index;
8596 1133 master_volume(digi_volume,midi_volume);
8597 1133 midi_paused=false;
8598 1133 }
8599
8600 8589 void jukebox(int32_t index)
8601 {
8602
1/2
✓ Branch 0 taken 8589 times.
✗ Branch 1 not taken.
8589 if(index<0) index=MAXMIDIS-1;
8603
8604
1/2
✓ Branch 0 taken 8589 times.
✗ Branch 1 not taken.
8589 if(index>=MAXMIDIS) index=0;
8605
8606 // do nothing if it's already playing
8607
3/4
✓ Branch 0 taken 7456 times.
✓ Branch 1 taken 1133 times.
✓ Branch 2 taken 7456 times.
✗ Branch 3 not taken.
8589 if(index==currmidi && midi_pos>=0)
8608 {
8609 7456 midi_paused=false;
8610 7456 return;
8611 }
8612
8613 1133 jukebox(index,tunes[index].loop);
8614 8589 }
8615
8616 9829 void play_DmapMusic()
8617 {
8618 static char tfile[2048];
8619 static int32_t ttrack=0;
8620 9829 bool domidi=false;
8621
8622
2/2
✓ Branch 0 taken 1330 times.
✓ Branch 1 taken 8499 times.
9829 if(DMaps[currdmap].tmusic[0]!=0)
8623 {
8624
3/4
✓ Branch 0 taken 385 times.
✓ Branch 1 taken 945 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 385 times.
1715 if(zcmusic==NULL ||
8625
1/2
✓ Branch 0 taken 385 times.
✗ Branch 1 not taken.
385 strcmp(zcmusic->filename,DMaps[currdmap].tmusic)!=0 ||
8626
1/2
✓ Branch 0 taken 385 times.
✗ Branch 1 not taken.
385 (zcmusic->type==ZCMF_GME && zcmusic->track != DMaps[currdmap].tmusictrack))
8627 {
8628
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 945 times.
945 if(zcmusic != NULL)
8629 {
8630 zcmusic_stop(zcmusic);
8631 zcmusic_unload_file(zcmusic);
8632 zcmusic = NULL;
8633 }
8634
8635 945 zcmusic = zcmusic_load_for_quest(DMaps[currdmap].tmusic, qstpath);
8636
8637
2/2
✓ Branch 0 taken 86 times.
✓ Branch 1 taken 859 times.
945 if(zcmusic!=NULL)
8638 {
8639 86 zc_stop_midi();
8640 86 strcpy(tfile,DMaps[currdmap].tmusic);
8641 86 zcmusic_play(zcmusic, emusic_volume);
8642 86 int32_t temptracks=0;
8643 86 temptracks=zcmusic_get_tracks(zcmusic);
8644
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 86 times.
86 temptracks=(temptracks<2)?1:temptracks;
8645 86 ttrack = vbound(DMaps[currdmap].tmusictrack,0,temptracks-1);
8646 86 zcmusic_change_track(zcmusic,ttrack);
8647 86 }
8648 else
8649 {
8650 859 tfile[0] = 0;
8651 859 domidi=true;
8652 }
8653 945 }
8654 1330 }
8655 else
8656 {
8657 8499 domidi=true;
8658 }
8659
8660
2/2
✓ Branch 0 taken 471 times.
✓ Branch 1 taken 9358 times.
9829 if(domidi)
8661 {
8662 9358 int32_t m=DMaps[currdmap].midi;
8663
8664
3/4
✓ Branch 0 taken 9243 times.
✓ Branch 1 taken 105 times.
✓ Branch 2 taken 10 times.
✗ Branch 3 not taken.
9358 switch(m)
8665 {
8666 case 1:
8667 105 jukebox(ZC_MIDI_OVERWORLD);
8668 105 break;
8669
8670 case 2:
8671 10 jukebox(ZC_MIDI_DUNGEON);
8672 10 break;
8673
8674 case 3:
8675 jukebox(ZC_MIDI_LEVEL9);
8676 break;
8677
8678 default:
8679
3/4
✓ Branch 0 taken 8329 times.
✓ Branch 1 taken 914 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8329 times.
9243 if(m>=4 && m<4+MAXCUSTOMMIDIS)
8680 8329 jukebox(m+MIDIOFFSET_DMAP);
8681 else
8682 914 music_stop();
8683 9243 }
8684 9358 }
8685 9829 }
8686
8687 9866 void playLevelMusic()
8688 {
8689 9866 int32_t m=tmpscr->screen_midi;
8690
8691
3/6
✓ Branch 0 taken 9813 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 41 times.
✓ Branch 4 taken 12 times.
✗ Branch 5 not taken.
9866 switch(m)
8692 {
8693 case -2:
8694 12 music_stop();
8695 12 break;
8696
8697 case -1:
8698 9813 play_DmapMusic();
8699 9813 break;
8700
8701 case 1:
8702 jukebox(ZC_MIDI_OVERWORLD);
8703 break;
8704
8705 case 2:
8706 jukebox(ZC_MIDI_DUNGEON);
8707 break;
8708
8709 case 3:
8710 jukebox(ZC_MIDI_LEVEL9);
8711 break;
8712
8713 default:
8714
2/4
✓ Branch 0 taken 41 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 41 times.
✗ Branch 3 not taken.
41 if(m>=4 && m<4+MAXCUSTOMMIDIS)
8715 41 jukebox(m+MIDIOFFSET_MAPSCR);
8716 else
8717 music_stop();
8718 41 }
8719 9866 }
8720
8721 1162 void master_volume(int32_t dv,int32_t mv)
8722 {
8723
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1162 times.
✓ Branch 2 taken 1162 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1162 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1162 times.
✗ Branch 7 not taken.
1162 if(dv>=0) digi_volume=zc_max(zc_min(dv,255),0);
8724
8725
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1162 times.
✓ Branch 2 taken 1162 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1162 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1162 times.
✗ Branch 7 not taken.
1162 if(mv>=0) midi_volume=zc_max(zc_min(mv,255),0);
8726
8727
6/6
✓ Branch 0 taken 1132 times.
✓ Branch 1 taken 30 times.
✓ Branch 2 taken 1160 times.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 1130 times.
✓ Branch 5 taken 30 times.
1162 int32_t i = zc_min(zc_max(currmidi,0),MAXMIDIS-1);
8728 1162 zc_set_volume(digi_volume,mixvol(tunes[i].volume,midi_volume));
8729 1162 }
8730
8731 /*****************/
8732 /***** SFX *****/
8733 /*****************/
8734
8735 // array of voices, one for each sfx sample in the data file
8736 // 0+ = voice #
8737 // -1 = voice not allocated
8738 29 void Z_init_sound()
8739 {
8740
2/2
✓ Branch 0 taken 7424 times.
✓ Branch 1 taken 29 times.
7453 for(int32_t i=0; i<WAV_COUNT; i++)
8741 7424 sfx_voice[i]=-1;
8742
8743
2/2
✓ Branch 0 taken 203 times.
✓ Branch 1 taken 29 times.
232 for(int32_t i=0; i<ZC_MIDI_COUNT; i++)
8744 203 tunes[i].data = (MIDI*)mididata[i].dat;
8745
8746
2/2
✓ Branch 0 taken 7308 times.
✓ Branch 1 taken 29 times.
7337 for(int32_t j=0; j<MAXCUSTOMMIDIS; j++)
8747 7308 tunes[ZC_MIDI_COUNT+j].data=NULL;
8748
8749 29 master_volume(digi_volume,midi_volume);
8750 29 }
8751
8752 // returns number of voices currently allocated
8753 int32_t sfx_count()
8754 {
8755 int32_t c=0;
8756
8757 for(int32_t i=0; i<WAV_COUNT; i++)
8758 if(sfx_voice[i]!=-1)
8759 ++c;
8760
8761 return c;
8762 }
8763
8764 // clean up finished samples
8765 6480723 void sfx_cleanup()
8766 {
8767
2/2
✓ Branch 0 taken 1659065088 times.
✓ Branch 1 taken 6480723 times.
1665545811 for(int32_t i=0; i<WAV_COUNT; i++)
8768
3/4
✓ Branch 0 taken 560755 times.
✓ Branch 1 taken 1658504333 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 560755 times.
1659625843 if(sfx_voice[i]!=-1 && voice_get_position(sfx_voice[i])<0)
8769 {
8770 560755 deallocate_voice(sfx_voice[i]);
8771 560755 sfx_voice[i]=-1;
8772 560755 }
8773 6480723 }
8774
8775 // allocates a voice for the sample "wav_index" (index into zelda.dat)
8776 // if a voice is already allocated (and/or playing), then it just returns true
8777 // Returns true: voice is allocated
8778 // false: unsuccessful
8779 838762 bool sfx_init(int32_t index)
8780 {
8781 // check index
8782
3/4
✓ Branch 0 taken 620761 times.
✓ Branch 1 taken 218001 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 620761 times.
838762 if(index<=0 || index>=WAV_COUNT)
8783 218001 return false;
8784
8785
2/2
✓ Branch 0 taken 59980 times.
✓ Branch 1 taken 560781 times.
620761 if(sfx_voice[index]==-1)
8786 {
8787
2/2
✓ Branch 0 taken 110294 times.
✓ Branch 1 taken 450487 times.
560781 if(sfxdat)
8788 {
8789
1/2
✓ Branch 0 taken 110294 times.
✗ Branch 1 not taken.
110294 if(index<Z35)
8790 {
8791 110294 sfx_voice[index]=allocate_voice((SAMPLE*)sfxdata[index].dat);
8792 110294 }
8793 else
8794 {
8795 sfx_voice[index]=allocate_voice((SAMPLE*)sfxdata[Z35].dat);
8796 }
8797 110294 }
8798 else
8799 {
8800 450487 sfx_voice[index]=allocate_voice(&customsfxdata[index]);
8801 }
8802
8803 560781 voice_set_volume(sfx_voice[index], sfx_volume);
8804 560781 }
8805
8806 620761 return sfx_voice[index] != -1;
8807 838762 }
8808
8809 // plays an sfx sample
8810 732250 void sfx(int32_t index,int32_t pan,bool loop, bool restart)
8811 {
8812
2/2
✓ Branch 0 taken 550996 times.
✓ Branch 1 taken 181254 times.
732250 if(!sfx_init(index))
8813 181254 return;
8814
8815 550996 voice_set_playmode(sfx_voice[index],loop?PLAYMODE_LOOP:PLAYMODE_PLAY);
8816 550996 voice_set_pan(sfx_voice[index],pan);
8817
8818 550996 int32_t pos = voice_get_position(sfx_voice[index]);
8819
8820
2/2
✓ Branch 0 taken 259936 times.
✓ Branch 1 taken 291060 times.
550996 if(restart) voice_set_position(sfx_voice[index],0);
8821
8822
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 550996 times.
550996 if(pos<=0)
8823 550996 voice_start(sfx_voice[index]);
8824
8825
3/4
✓ Branch 0 taken 291060 times.
✓ Branch 1 taken 259936 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 291060 times.
550996 if (restart && replay_is_debug())
8826
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 291060 times.
291060 replay_step_comment(fmt::format("sfx {}", sfx_string[index]));
8827 732250 }
8828
8829 // true if sfx is allocated
8830 32243 bool sfx_allocated(int32_t index)
8831 {
8832
3/4
✓ Branch 0 taken 9403 times.
✓ Branch 1 taken 22840 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9403 times.
32243 return (index>0 && index<WAV_COUNT && sfx_voice[index]!=-1);
8833 }
8834
8835 // start it (in loop mode) if it's not already playing,
8836 // otherwise adjust it to play in loop mode -DD
8837 106512 void cont_sfx(int32_t index)
8838 {
8839
2/2
✓ Branch 0 taken 36747 times.
✓ Branch 1 taken 69765 times.
106512 if(!sfx_init(index))
8840 {
8841 36747 return;
8842 }
8843
8844
1/2
✓ Branch 0 taken 69765 times.
✗ Branch 1 not taken.
69765 if(voice_get_position(sfx_voice[index])<=0)
8845 {
8846 69765 voice_set_position(sfx_voice[index],0);
8847 69765 voice_set_playmode(sfx_voice[index],PLAYMODE_LOOP);
8848 69765 voice_start(sfx_voice[index]);
8849 69765 }
8850 else
8851 {
8852 adjust_sfx(index, 128, true);
8853 }
8854 106512 }
8855
8856 // adjust parameters while playing
8857 3547 void adjust_sfx(int32_t index,int32_t pan,bool loop)
8858 {
8859
5/6
✓ Branch 0 taken 2124 times.
✓ Branch 1 taken 1423 times.
✓ Branch 2 taken 2124 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 14 times.
✓ Branch 5 taken 2110 times.
3547 if(index<=0 || index>=WAV_COUNT || sfx_voice[index]==-1)
8860 3533 return;
8861
8862 14 voice_set_playmode(sfx_voice[index],loop?PLAYMODE_LOOP:PLAYMODE_PLAY);
8863 14 voice_set_pan(sfx_voice[index],pan);
8864 3547 }
8865
8866 // pauses a voice
8867 1468 void pause_sfx(int32_t index)
8868 {
8869
3/6
✓ Branch 0 taken 1468 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1468 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1468 times.
1468 if(index>0 && index<WAV_COUNT && sfx_voice[index]!=-1)
8870 voice_stop(sfx_voice[index]);
8871 1468 }
8872
8873 // resumes a voice
8874 637 void resume_sfx(int32_t index)
8875 {
8876
3/6
✓ Branch 0 taken 637 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 637 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 637 times.
637 if(index>0 && index<WAV_COUNT && sfx_voice[index]!=-1)
8877 voice_start(sfx_voice[index]);
8878 637 }
8879
8880 // pauses all active voices
8881 244 void pause_all_sfx()
8882 {
8883
2/2
✓ Branch 0 taken 62464 times.
✓ Branch 1 taken 244 times.
62708 for(int32_t i=0; i<WAV_COUNT; i++)
8884
2/2
✓ Branch 0 taken 62462 times.
✓ Branch 1 taken 2 times.
62466 if(sfx_voice[i]!=-1)
8885 2 voice_stop(sfx_voice[i]);
8886 244 }
8887
8888 // resumes all paused voices
8889 230 void resume_all_sfx()
8890 {
8891
2/2
✓ Branch 0 taken 58880 times.
✓ Branch 1 taken 230 times.
59110 for(int32_t i=0; i<WAV_COUNT; i++)
8892
1/2
✓ Branch 0 taken 58880 times.
✗ Branch 1 not taken.
58880 if(sfx_voice[i]!=-1)
8893 voice_start(sfx_voice[i]);
8894 230 }
8895
8896 // stops an sfx and deallocates the voice
8897 5203476 void stop_sfx(int32_t index)
8898 {
8899
3/4
✓ Branch 0 taken 5102116 times.
✓ Branch 1 taken 101360 times.
✓ Branch 2 taken 5102116 times.
✗ Branch 3 not taken.
5203476 if(index<=0 || index>=WAV_COUNT)
8900 101360 return;
8901
8902
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 5102103 times.
5102116 if(sfx_voice[index]!=-1)
8903 {
8904 13 deallocate_voice(sfx_voice[index]);
8905 13 sfx_voice[index]=-1;
8906 13 }
8907 5203476 }
8908
8909 // Stops SFX played by Hero's item of the given family
8910 131169 void stop_item_sfx(int32_t family)
8911 {
8912 131169 int32_t id=current_item_id(family);
8913
8914
2/2
✓ Branch 0 taken 130841 times.
✓ Branch 1 taken 328 times.
131169 if(id<0)
8915 130841 return;
8916
8917 328 stop_sfx(itemsbuf[id].usesound);
8918 131169 }
8919
8920 1802 void kill_sfx()
8921 {
8922
2/2
✓ Branch 0 taken 461312 times.
✓ Branch 1 taken 1802 times.
463114 for(int32_t i=0; i<WAV_COUNT; i++)
8923
2/2
✓ Branch 0 taken 461299 times.
✓ Branch 1 taken 13 times.
461325 if(sfx_voice[i]!=-1)
8924 {
8925 13 deallocate_voice(sfx_voice[i]);
8926 13 sfx_voice[i]=-1;
8927 13 }
8928 1802 }
8929
8930 504198 int32_t pan(int32_t x)
8931 {
8932
1/4
✓ Branch 0 taken 504198 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
504198 switch(pan_style)
8933 {
8934 case 0:
8935 return 128;
8936
8937 case 1:
8938 504198 return vbound((x>>1)+68,0,255);
8939
8940 case 2:
8941 return vbound(((x*3)>>2)+36,0,255);
8942 }
8943
8944 return vbound(x,0,255);
8945 504198 }
8946
8947 /*******************************/
8948 /******* Input Handlers ********/
8949 /*******************************/
8950
8951 16584516 bool joybtn(int32_t b)
8952 {
8953
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16584516 times.
16584516 if(b == 0)
8954 return false;
8955
8956 16584516 return joy[joystick_index].button[b-1].b !=0;
8957 16584516 }
8958
8959 const char* joybtn_name(int32_t b)
8960 {
8961 if(b == 0)
8962 return "";
8963
8964 return joy[joystick_index].button[b-1].name;
8965 }
8966
8967 int32_t next_press_key();
8968
8969 int32_t next_press_btn()
8970 {
8971 clear_keybuf();
8972 /*bool b[joy[joystick_index].num_buttons+1];
8973
8974 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
8975 b[i]=joybtn(i);*/
8976
8977 //first, we need to wait until they're pressing no buttons
8978 for(;;)
8979 {
8980 if(keypressed())
8981 {
8982 switch(readkey()>>8)
8983 {
8984 case KEY_ESC:
8985 return -1;
8986
8987 case KEY_SPACE:
8988 return 0;
8989 }
8990 }
8991
8992 poll_joystick();
8993 bool done = true;
8994
8995 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
8996 {
8997 if(joybtn(i)) done = false;
8998 }
8999
9000 if(done) break;
9001 rest(1);
9002 }
9003
9004 //now, we need to wait for them to press any button
9005 for(;;)
9006 {
9007 if(keypressed())
9008 {
9009 switch(readkey()>>8)
9010 {
9011 case KEY_ESC:
9012 return -1;
9013
9014 case KEY_SPACE:
9015 return 0;
9016 }
9017 }
9018
9019 poll_joystick();
9020
9021 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
9022 {
9023 if(joybtn(i)) return i;
9024 }
9025 rest(1);
9026 }
9027 }
9028
9029 134574253 static bool rButton(bool &btn, bool &flag, bool* rawbtn = nullptr)
9030 {
9031
2/2
✓ Branch 0 taken 129784481 times.
✓ Branch 1 taken 4789772 times.
134574253 bool ret = btn && !flag;
9032
2/2
✓ Branch 0 taken 117573131 times.
✓ Branch 1 taken 17001122 times.
134574253 flag = rawbtn ? *rawbtn : btn;
9033
9034 134574253 return ret;
9035 }
9036 1337132 static bool rButtonPeek(bool btn, bool flag)
9037 {
9038
2/2
✓ Branch 0 taken 1249424 times.
✓ Branch 1 taken 87708 times.
1337132 if(!btn)
9039 {
9040 1249424 return false;
9041 }
9042
2/2
✓ Branch 0 taken 14956 times.
✓ Branch 1 taken 72752 times.
87708 else if(!flag)
9043 {
9044 14956 return true;
9045 }
9046
9047 72752 return false;
9048 1337132 }
9049
9050 // Updated only by keyboard/gamepad.
9051 // If in replay mode, this is set directly by the replay system.
9052 // This should never be read from directly - use control_state instead.
9053 bool raw_control_state[ZC_CONTROL_STATES];
9054
9055 // Every call to load_control_state (pretty much every frame) resets this to be equal to raw_control_state.
9056 // This state can drift from raw_control_state if button states are "eaten" or overriden by a script. But that only
9057 // lasts until the next call to load_control_state.
9058 bool control_state[ZC_CONTROL_STATES];
9059 bool disable_control[ZC_CONTROL_STATES];
9060 bool drunk_toggle_state[11];
9061 bool disabledKeys[127];
9062 bool KeyInput[127];
9063 bool KeyPress[127];
9064
9065 bool key_current_frame[127];
9066 bool key_previous_frame[127];
9067
9068 static bool key_system[127];
9069 static bool key_system_previous[127];
9070 static bool key_system_press[127];
9071
9072 bool button_press[ZC_CONTROL_STATES];
9073 bool button_hold[ZC_CONTROL_STATES];
9074
9075 #define STICK_1_X joy[joystick_index].stick[js_stick_1_x_stick].axis[js_stick_1_x_axis]
9076 #define STICK_1_Y joy[joystick_index].stick[js_stick_1_y_stick].axis[js_stick_1_y_axis]
9077 #define STICK_2_X joy[joystick_index].stick[js_stick_2_x_stick].axis[js_stick_2_x_axis]
9078 #define STICK_2_Y joy[joystick_index].stick[js_stick_2_y_stick].axis[js_stick_2_y_axis]
9079 #define STICK_PRECISION 56 //define your own sensitivity
9080
9081 5438197 void load_control_state()
9082 {
9083 5438197 load_control_called_this_frame = true;
9084
9085
3/4
✓ Branch 0 taken 2566996 times.
✓ Branch 1 taken 2871201 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2566996 times.
5438197 if (replay_get_version() >= 8 && replay_get_version() < 11)
9086 {
9087
2/2
✓ Branch 0 taken 46205928 times.
✓ Branch 1 taken 2566996 times.
48772924 for (int i = 0; i < ZC_CONTROL_STATES; i++)
9088 46205928 down_control_states[i] = raw_control_state[i];
9089 2566996 }
9090
9091
1/2
✓ Branch 0 taken 5438197 times.
✗ Branch 1 not taken.
5438197 if (!replay_is_replaying())
9092 {
9093 raw_control_state[0]=zc_getrawkey(DUkey, true)||(analog_movement ? STICK_1_Y.d1 || STICK_1_Y.pos - js_stick_1_y_offset < -STICK_PRECISION : joybtn(DUbtn));
9094 raw_control_state[1]=zc_getrawkey(DDkey, true)||(analog_movement ? STICK_1_Y.d2 || STICK_1_Y.pos - js_stick_1_y_offset > STICK_PRECISION : joybtn(DDbtn));
9095 raw_control_state[2]=zc_getrawkey(DLkey, true)||(analog_movement ? STICK_1_X.d1 || STICK_1_X.pos - js_stick_1_x_offset < -STICK_PRECISION : joybtn(DLbtn));
9096 raw_control_state[3]=zc_getrawkey(DRkey, true)||(analog_movement ? STICK_1_X.d2 || STICK_1_X.pos - js_stick_1_x_offset > STICK_PRECISION : joybtn(DRbtn));
9097 raw_control_state[4]=zc_getrawkey(Akey, true)||joybtn(Abtn);
9098 raw_control_state[5]=zc_getrawkey(Bkey, true)||joybtn(Bbtn);
9099 raw_control_state[6]=zc_getrawkey(Skey, true)||joybtn(Sbtn);
9100 raw_control_state[7]=zc_getrawkey(Lkey, true)||joybtn(Lbtn);
9101 raw_control_state[8]=zc_getrawkey(Rkey, true)||joybtn(Rbtn);
9102 raw_control_state[9]=zc_getrawkey(Pkey, true)||joybtn(Pbtn);
9103 raw_control_state[10]=zc_getrawkey(Exkey1, true)||joybtn(Exbtn1);
9104 raw_control_state[11]=zc_getrawkey(Exkey2, true)||joybtn(Exbtn2);
9105 raw_control_state[12]=zc_getrawkey(Exkey3, true)||joybtn(Exbtn3);
9106 raw_control_state[13]=zc_getrawkey(Exkey4, true)||joybtn(Exbtn4);
9107
9108 if(num_joysticks != 0)
9109 {
9110 raw_control_state[14] = STICK_2_Y.pos - js_stick_2_y_offset < -STICK_PRECISION;
9111 raw_control_state[15] = STICK_2_Y.pos - js_stick_2_y_offset > STICK_PRECISION;
9112 raw_control_state[16] = STICK_2_X.pos - js_stick_2_x_offset < -STICK_PRECISION;
9113 raw_control_state[17] = STICK_2_X.pos - js_stick_2_x_offset > STICK_PRECISION;
9114 // zprint2("Detected %d joysticks... %d%d%d%d\n", num_joysticks, raw_control_state[14]?1:0, raw_control_state[15]?1:0, raw_control_state[16]?1:0, raw_control_state[17]?1:0);
9115 }
9116 else
9117 {
9118 raw_control_state[14] = false;
9119 raw_control_state[15] = false;
9120 raw_control_state[16] = false;
9121 raw_control_state[17] = false;
9122 // zprint2("Detected 0 joysticks... clearing inputaxis values.\n");
9123 }
9124 }
9125
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 5438194 times.
5438197 if (replay_is_active())
9126 {
9127
2/2
✓ Branch 0 taken 1015215 times.
✓ Branch 1 taken 4422979 times.
5438194 if (replay_get_version() < 3)
9128 1015215 replay_poll();
9129
3/4
✓ Branch 0 taken 4422979 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2661604 times.
✓ Branch 3 taken 1761375 times.
4422979 else if (replay_is_replaying() && replay_get_version() < 6)
9130 1761375 replay_peek_input();
9131
4/6
✓ Branch 0 taken 2661604 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2566996 times.
✓ Branch 3 taken 94608 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2566996 times.
2661604 else if (replay_is_replaying() && replay_get_version() >= 8 && replay_get_version() < 11)
9132 2566996 replay_peek_input();
9133
2/2
✓ Branch 0 taken 4320728 times.
✓ Branch 1 taken 1117466 times.
5438194 if (replay_get_version() == 8)
9134 1117466 update_keys();
9135 5438194 }
9136
9137 // Some test replay files were made before a serious input bug was fixed, so instead
9138 // of re-doing them or tossing them out, just check for that zplay version.
9139
3/4
✓ Branch 0 taken 5438191 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 121900 times.
✓ Branch 3 taken 5316291 times.
5438197 bool botched_input = replay_is_active() && replay_get_version() != 1 && replay_get_version() < 8;
9140
2/2
✓ Branch 0 taken 97887438 times.
✓ Branch 1 taken 5438191 times.
103325629 for (int i = 0; i < ZC_CONTROL_STATES; i++)
9141 {
9142 97887438 control_state[i] = raw_control_state[i];
9143
4/4
✓ Branch 0 taken 49487310 times.
✓ Branch 1 taken 48400128 times.
✓ Branch 2 taken 2410168 times.
✓ Branch 3 taken 47077142 times.
97887438 if (botched_input && !control_state[i])
9144 47077142 down_control_states[i] = false;
9145 97887438 }
9146
9147 5438191 button_press[0]=rButton(control_state[0],button_hold[0]);
9148 5438191 button_press[1]=rButton(control_state[1],button_hold[1]);
9149 5438191 button_press[2]=rButton(control_state[2],button_hold[2]);
9150 5438191 button_press[3]=rButton(control_state[3],button_hold[3]);
9151 5438191 button_press[4]=rButton(control_state[4],button_hold[4]);
9152 5438191 button_press[5]=rButton(control_state[5],button_hold[5]);
9153 5438191 button_press[6]=rButton(control_state[6],button_hold[6]);
9154 5438191 button_press[7]=rButton(control_state[7],button_hold[7]);
9155 5438191 button_press[8]=rButton(control_state[8],button_hold[8]);
9156 5438191 button_press[9]=rButton(control_state[9],button_hold[9]);
9157 5438191 button_press[10]=rButton(control_state[10],button_hold[10]);
9158 5438191 button_press[11]=rButton(control_state[11],button_hold[11]);
9159 5438191 button_press[12]=rButton(control_state[12],button_hold[12]);
9160 5438191 button_press[13]=rButton(control_state[13],button_hold[13]);
9161 5438191 button_press[14]=rButton(control_state[14],button_hold[14]);
9162 5438191 button_press[15]=rButton(control_state[15],button_hold[15]);
9163 5438191 button_press[16]=rButton(control_state[16],button_hold[16]);
9164 5438191 button_press[17]=rButton(control_state[17],button_hold[17]);
9165 5438191 }
9166
9167 // Returns true if any game key is pressed. This is needed because keypressed()
9168 // doesn't detect modifier keys and control_state[] can be modified by scripts.
9169 28178162 bool zc_key_pressed()
9170 //may also need to use zc_getrawkey
9171 {
9172
7/10
✓ Branch 0 taken 22800161 times.
✓ Branch 1 taken 5378001 times.
✓ Branch 2 taken 5378001 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5378001 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4533401 times.
✓ Branch 7 taken 4533401 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 1621032 times.
29799194 if((zc_getrawkey(DUkey, true)||(analog_movement ? STICK_1_Y.d1 || STICK_1_Y.pos - js_stick_1_y_offset< -STICK_PRECISION : joybtn(DUbtn))) ||
9173
4/6
✓ Branch 0 taken 4533401 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4533401 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3418530 times.
✓ Branch 5 taken 3418530 times.
4533401 (zc_getrawkey(DDkey, true)||(analog_movement ? STICK_1_Y.d2 || STICK_1_Y.pos - js_stick_1_y_offset > STICK_PRECISION : joybtn(DDbtn))) ||
9174
4/6
✓ Branch 0 taken 3418530 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3418530 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2176173 times.
✓ Branch 5 taken 2176173 times.
3418530 (zc_getrawkey(DLkey, true)||(analog_movement ? STICK_1_X.d1 || STICK_1_X.pos - js_stick_1_x_offset < -STICK_PRECISION : joybtn(DLbtn))) ||
9175
4/6
✓ Branch 0 taken 2176173 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2176173 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1838283 times.
✓ Branch 5 taken 1838283 times.
2176173 (zc_getrawkey(DRkey, true)||(analog_movement ? STICK_1_X.d2 || STICK_1_X.pos - js_stick_1_x_offset > STICK_PRECISION : joybtn(DRbtn))) ||
9176
1/2
✓ Branch 0 taken 1838283 times.
✗ Branch 1 not taken.
1838283 (zc_getrawkey(Akey, true)||joybtn(Abtn)) ||
9177
3/4
✓ Branch 0 taken 1736661 times.
✓ Branch 1 taken 101622 times.
✓ Branch 2 taken 1736661 times.
✗ Branch 3 not taken.
1838283 (zc_getrawkey(Bkey, true)||joybtn(Bbtn)) ||
9178
3/4
✓ Branch 0 taken 1646160 times.
✓ Branch 1 taken 90501 times.
✓ Branch 2 taken 1646160 times.
✗ Branch 3 not taken.
1736661 (zc_getrawkey(Skey, true)||joybtn(Sbtn)) ||
9179
3/4
✓ Branch 0 taken 1633476 times.
✓ Branch 1 taken 12684 times.
✓ Branch 2 taken 1633476 times.
✗ Branch 3 not taken.
1646160 (zc_getrawkey(Lkey, true)||joybtn(Lbtn)) ||
9180
3/4
✓ Branch 0 taken 1623117 times.
✓ Branch 1 taken 10359 times.
✓ Branch 2 taken 1623117 times.
✗ Branch 3 not taken.
1633476 (zc_getrawkey(Rkey, true)||joybtn(Rbtn)) ||
9181
3/4
✓ Branch 0 taken 1621864 times.
✓ Branch 1 taken 1253 times.
✓ Branch 2 taken 1621864 times.
✗ Branch 3 not taken.
1623117 (zc_getrawkey(Pkey, true)||joybtn(Pbtn)) ||
9182
3/4
✓ Branch 0 taken 1621821 times.
✓ Branch 1 taken 43 times.
✓ Branch 2 taken 1621821 times.
✗ Branch 3 not taken.
1621864 (zc_getrawkey(Exkey1, true)||joybtn(Exbtn1)) ||
9183
3/4
✓ Branch 0 taken 1621051 times.
✓ Branch 1 taken 770 times.
✓ Branch 2 taken 1621051 times.
✗ Branch 3 not taken.
1621821 (zc_getrawkey(Exkey2, true)||joybtn(Exbtn2)) ||
9184
2/4
✓ Branch 0 taken 1621051 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1621051 times.
✗ Branch 3 not taken.
1621051 (zc_getrawkey(Exkey3, true)||joybtn(Exbtn3)) ||
9185
2/2
✓ Branch 0 taken 1621032 times.
✓ Branch 1 taken 19 times.
1621051 (zc_getrawkey(Exkey4, true)||joybtn(Exbtn4))) // Skipping joystick axes
9186 50489904 return true;
9187
9188 1621032 return false;
9189 6510614 }
9190
9191 108529366 bool getInput(int32_t btn, bool press, bool drunk, bool ignoreDisable, bool eatEntirely, bool peek)
9192 {
9193 108529366 bool ret = false, drunkstate = false, rawret = false;
9194 108529366 bool* flag = &down_control_states[btn];
9195
2/7
✓ Branch 0 taken 102011933 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 6517433 times.
108529366 switch(btn)
9196 {
9197 case btnF12:
9198 ret = zc_getkey(KEY_F12, ignoreDisable);
9199 rawret = zc_getrawkey(KEY_F12, ignoreDisable);
9200 eatEntirely = false;
9201 break;
9202 case btnF11:
9203 ret = zc_getkey(KEY_F11, ignoreDisable);
9204 rawret = zc_getrawkey(KEY_F11, ignoreDisable);
9205 eatEntirely = false;
9206 break;
9207 case btnF5:
9208 ret = zc_getkey(KEY_F5, ignoreDisable);
9209 rawret = zc_getrawkey(KEY_F5, ignoreDisable);
9210 eatEntirely = false;
9211 break;
9212 case btnQ:
9213 ret = zc_getkey(KEY_Q, ignoreDisable);
9214 rawret = zc_getrawkey(KEY_Q, ignoreDisable);
9215 eatEntirely = false;
9216 break;
9217 case btnI:
9218 ret = zc_getkey(KEY_I, ignoreDisable);
9219 rawret = zc_getrawkey(KEY_I, ignoreDisable);
9220 eatEntirely = false;
9221 break;
9222 case btnM:
9223
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6517433 times.
6517433 if(FFCore.kb_typing_mode) return false;
9224 6517433 rawret = ret = zc_getrawkey(KEY_ESC, ignoreDisable);
9225 6517433 eatEntirely = false;
9226 6517433 break;
9227 default: //control_state[] index
9228
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102011933 times.
102011933 if(FFCore.kb_typing_mode) return false;
9229
5/6
✓ Branch 0 taken 101784203 times.
✓ Branch 1 taken 227730 times.
✓ Branch 2 taken 2257162 times.
✓ Branch 3 taken 99527041 times.
✓ Branch 4 taken 2257162 times.
✗ Branch 5 not taken.
102011933 if(!ignoreDisable && get_bit(quest_rules, qr_FIXDRUNKINPUTS) && disable_control[btn]) drunk = false;
9230
2/2
✓ Branch 0 taken 5491613 times.
✓ Branch 1 taken 96520320 times.
102011933 else if(btn<11) drunkstate = drunk_toggle_state[btn];
9231
4/4
✓ Branch 0 taken 91845546 times.
✓ Branch 1 taken 10166387 times.
✓ Branch 2 taken 1395 times.
✓ Branch 3 taken 10164992 times.
112178320 ret = control_state[btn] && (ignoreDisable || !disable_control[btn]);
9232 102011933 rawret = raw_control_state[btn];
9233 102011933 }
9234
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 108529366 times.
108529366 assert(flag);
9235
2/2
✓ Branch 0 taken 70505419 times.
✓ Branch 1 taken 38023947 times.
108529366 if(press)
9236 {
9237
2/2
✓ Branch 0 taken 1337132 times.
✓ Branch 1 taken 36686815 times.
38023947 if(peek)
9238 1337132 ret = rButtonPeek(ret, *flag);
9239
3/4
✓ Branch 0 taken 36686815 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17001122 times.
✓ Branch 3 taken 19685693 times.
36686815 else if (replay_is_active() && replay_get_version() < 8) ret = rButton(ret, *flag);
9240 17001122 else ret = rButton(ret, *flag, &rawret);
9241 38023947 }
9242
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 108529366 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
108529366 if(eatEntirely && ret) control_state[btn] = false;
9243
3/4
✓ Branch 0 taken 82010678 times.
✓ Branch 1 taken 26518688 times.
✓ Branch 2 taken 82010678 times.
✗ Branch 3 not taken.
108529366 if(drunk && drunkstate) ret = !ret;
9244 108529366 return ret;
9245 108529366 }
9246
9247 5384201 byte getIntBtnInput(byte intbtn, bool press, bool drunk, bool ignoreDisable, bool eatEntirely, bool peek)
9248 {
9249 5384201 byte ret = 0;
9250
2/2
✓ Branch 0 taken 4045008 times.
✓ Branch 1 taken 1339193 times.
5384201 if(intbtn & INT_BTN_A) ret |= getInput(btnA, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_A : 0;
9251
2/2
✓ Branch 0 taken 5383639 times.
✓ Branch 1 taken 562 times.
5384201 if(intbtn & INT_BTN_B) ret |= getInput(btnB, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_B : 0;
9252
2/2
✓ Branch 0 taken 5383764 times.
✓ Branch 1 taken 437 times.
5384201 if(intbtn & INT_BTN_L) ret |= getInput(btnL, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_L : 0;
9253
2/2
✓ Branch 0 taken 5383764 times.
✓ Branch 1 taken 437 times.
5384201 if(intbtn & INT_BTN_R) ret |= getInput(btnR, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_R : 0;
9254
2/2
✓ Branch 0 taken 5383764 times.
✓ Branch 1 taken 437 times.
5384201 if(intbtn & INT_BTN_EX1) ret |= getInput(btnEx1, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX1 : 0;
9255
2/2
✓ Branch 0 taken 5383764 times.
✓ Branch 1 taken 437 times.
5384201 if(intbtn & INT_BTN_EX2) ret |= getInput(btnEx2, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX2 : 0;
9256
2/2
✓ Branch 0 taken 5383764 times.
✓ Branch 1 taken 437 times.
5384201 if(intbtn & INT_BTN_EX3) ret |= getInput(btnEx3, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX3 : 0;
9257
2/2
✓ Branch 0 taken 5383764 times.
✓ Branch 1 taken 437 times.
5384201 if(intbtn & INT_BTN_EX4) ret |= getInput(btnEx4, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX4 : 0;
9258 5384201 return ret; //No early return, to make sure all button presses are eaten that should be! -Em
9259 }
9260
9261 1114 byte checkIntBtnVal(byte intbtn, byte vals)
9262 {
9263 1114 return intbtn&vals;
9264 }
9265
9266 1281348 bool Up()
9267 {
9268 1281348 return getInput(btnUp);
9269 }
9270 77421 bool Down()
9271 {
9272 77421 return getInput(btnDown);
9273 }
9274 167324 bool Left()
9275 {
9276 167324 return getInput(btnLeft);
9277 }
9278 188659 bool Right()
9279 {
9280 188659 return getInput(btnRight);
9281 }
9282 68115 bool cAbtn()
9283 {
9284 68115 return getInput(btnA);
9285 }
9286 1255212 bool cBbtn()
9287 {
9288 1255212 return getInput(btnB);
9289 }
9290 bool cSbtn()
9291 {
9292 return getInput(btnS);
9293 }
9294 29891 bool cLbtn()
9295 {
9296 29891 return getInput(btnL);
9297 }
9298 29891 bool cRbtn()
9299 {
9300 29891 return getInput(btnR);
9301 }
9302 bool cPbtn()
9303 {
9304 return getInput(btnP);
9305 }
9306 bool cEx1btn()
9307 {
9308 return getInput(btnEx1);
9309 }
9310 bool cEx2btn()
9311 {
9312 return getInput(btnEx2);
9313 }
9314 bool cEx3btn()
9315 {
9316 return getInput(btnEx3);
9317 }
9318 bool cEx4btn()
9319 {
9320 return getInput(btnEx4);
9321 }
9322 bool AxisUp()
9323 {
9324 return getInput(btnAxisUp);
9325 }
9326 bool AxisDown()
9327 {
9328 return getInput(btnAxisDown);
9329 }
9330 bool AxisLeft()
9331 {
9332 return getInput(btnAxisLeft);
9333 }
9334 bool AxisRight()
9335 {
9336 return getInput(btnAxisRight);
9337 }
9338
9339 bool cMbtn()
9340 {
9341 return getInput(btnM);
9342 }
9343 bool cF12()
9344 {
9345 return getInput(btnF12);
9346 }
9347 bool cF11()
9348 {
9349 return getInput(btnF11);
9350 }
9351 bool cF5()
9352 {
9353 return getInput(btnF5);
9354 }
9355 bool cQ()
9356 {
9357 return getInput(btnQ);
9358 }
9359 bool cI()
9360 {
9361 return getInput(btnI);
9362 }
9363
9364 112876 bool rUp()
9365 {
9366 112876 return getInput(btnUp, true);
9367 }
9368 112804 bool rDown()
9369 {
9370 112804 return getInput(btnDown, true);
9371 }
9372 112757 bool rLeft()
9373 {
9374 112757 return getInput(btnLeft, true);
9375 }
9376 112309 bool rRight()
9377 {
9378 112309 return getInput(btnRight, true);
9379 }
9380 2482 bool rAbtn()
9381 {
9382 2482 return getInput(btnA, true);
9383 }
9384 113491 bool rBbtn()
9385 {
9386 113491 return getInput(btnB, true);
9387 }
9388 5266505 bool rSbtn()
9389 {
9390 5266505 return getInput(btnS, true);
9391 }
9392 6510614 bool rMbtn()
9393 {
9394 6510614 return getInput(btnM, true);
9395 }
9396 112109 bool rLbtn()
9397 {
9398 112109 return getInput(btnL, true);
9399 }
9400 112106 bool rRbtn()
9401 {
9402 112106 return getInput(btnR, true);
9403 }
9404 5182404 bool rPbtn()
9405 {
9406 5182404 return getInput(btnP, true);
9407 }
9408 bool rEx1btn()
9409 {
9410 return getInput(btnEx1, true);
9411 }
9412 bool rEx2btn()
9413 {
9414 return getInput(btnEx2, true);
9415 }
9416 122985 bool rEx3btn()
9417 {
9418 122985 return getInput(btnEx3, true);
9419 }
9420 122985 bool rEx4btn()
9421 {
9422 122985 return getInput(btnEx4, true);
9423 }
9424 bool rAxisUp()
9425 {
9426 return getInput(btnAxisUp, true);
9427 }
9428 bool rAxisDown()
9429 {
9430 return getInput(btnAxisDown, true);
9431 }
9432 bool rAxisLeft()
9433 {
9434 return getInput(btnAxisLeft, true);
9435 }
9436 bool rAxisRight()
9437 {
9438 return getInput(btnAxisRight, true);
9439 }
9440
9441 bool rF11()
9442 {
9443 return getInput(btnF11, true);
9444 }
9445 bool rQ()
9446 {
9447 return getInput(btnQ, true);
9448 }
9449 bool rI()
9450 {
9451 return getInput(btnI, true);
9452 }
9453
9454 13317771 bool DrunkUp()
9455 {
9456 13317771 return getInput(btnUp, false, true);
9457 }
9458 12417217 bool DrunkDown()
9459 {
9460 12417217 return getInput(btnDown, false, true);
9461 }
9462 7866450 bool DrunkLeft()
9463 {
9464 7866450 return getInput(btnLeft, false, true);
9465 }
9466 6829749 bool DrunkRight()
9467 {
9468 6829749 return getInput(btnRight, false, true);
9469 }
9470 5759186 bool DrunkcAbtn()
9471 {
9472 5759186 return getInput(btnA, false, true);
9473 }
9474 5722928 bool DrunkcBbtn()
9475 {
9476 5722928 return getInput(btnB, false, true);
9477 }
9478 5152193 bool DrunkcEx1btn()
9479 {
9480 5152193 return getInput(btnEx1, false, true);
9481 }
9482 5152213 bool DrunkcEx2btn()
9483 {
9484 5152213 return getInput(btnEx2, false, true);
9485 }
9486 bool DrunkcSbtn()
9487 {
9488 return getInput(btnS, false, true);
9489 }
9490 bool DrunkcMbtn()
9491 {
9492 return getInput(btnM, false, true);
9493 }
9494 bool DrunkcLbtn()
9495 {
9496 return getInput(btnL, false, true);
9497 }
9498 bool DrunkcRbtn()
9499 {
9500 return getInput(btnR, false, true);
9501 }
9502 bool DrunkcPbtn()
9503 {
9504 return getInput(btnP, false, true);
9505 }
9506
9507 bool DrunkrUp()
9508 {
9509 return getInput(btnUp, true, true);
9510 }
9511 bool DrunkrDown()
9512 {
9513 return getInput(btnDown, true, true);
9514 }
9515 bool DrunkrLeft()
9516 {
9517 return getInput(btnLeft, true, true);
9518 }
9519 bool DrunkrRight()
9520 {
9521 return getInput(btnRight, true, true);
9522 }
9523 4315794 bool DrunkrAbtn()
9524 {
9525 4315794 return getInput(btnA, true, true);
9526 }
9527 4328323 bool DrunkrBbtn()
9528 {
9529 4328323 return getInput(btnB, true, true);
9530 }
9531 71669 bool DrunkrEx1btn()
9532 {
9533 71669 return getInput(btnEx1, true, true);
9534 }
9535 71662 bool DrunkrEx2btn()
9536 {
9537 71662 return getInput(btnEx2, true, true);
9538 }
9539 bool DrunkrEx3btn()
9540 {
9541 return getInput(btnEx3, true, true);
9542 }
9543 bool DrunkrEx4btn()
9544 {
9545 return getInput(btnEx4, true, true);
9546 }
9547 bool DrunkrSbtn()
9548 {
9549 return getInput(btnS, true, true);
9550 }
9551 bool DrunkrMbtn()
9552 {
9553 return getInput(btnM, true, true);
9554 }
9555 4832892 bool DrunkrLbtn()
9556 {
9557 4832892 return getInput(btnL, true, true);
9558 }
9559 4830254 bool DrunkrRbtn()
9560 {
9561 4830254 return getInput(btnR, true, true);
9562 }
9563 bool DrunkrPbtn()
9564 {
9565 return getInput(btnP, true, true);
9566 }
9567
9568 6819 void eat_buttons()
9569 {
9570 6819 getInput(btnA, true, false, true);
9571 6819 getInput(btnB, true, false, true);
9572 6819 getInput(btnS, true, false, true);
9573 6819 getInput(btnM, true, false, true);
9574 6819 getInput(btnL, true, false, true);
9575 6819 getInput(btnR, true, false, true);
9576 6819 getInput(btnP, true, false, true);
9577 6819 getInput(btnEx1, true, false, true);
9578 6819 getInput(btnEx2, true, false, true);
9579 6819 getInput(btnEx3, true, false, true);
9580 6819 getInput(btnEx4, true, false, true);
9581 6819 }
9582
9583 // Is true for the _first frame_ of a key press.
9584 // But! it is possible that a script manually sets the value of KeyPress,
9585 // in which case it will be restored to the "true" value based on `key_current_frame`
9586 // and `key_previous_frame` on the next frame.
9587 14 bool zc_readkey(int32_t k, bool ignoreDisable)
9588 {
9589
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(ignoreDisable) return KeyPress[k];
9590
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 switch(k)
9591 {
9592 case KEY_F7:
9593 case KEY_F8:
9594 case KEY_F9:
9595 return KeyPress[k];
9596
9597 default:
9598
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 1 times.
14 return KeyPress[k] && !disabledKeys[k];
9599 }
9600 14 }
9601
9602 // Is true for _every frame_ a key is held down.
9603 // But! it is possible that a script manually sets the value of KeyInput,
9604 // in which case it will be restored to the "true" value based on `key_current_frame`
9605 // on the next frame.
9606 bool zc_getkey(int32_t k, bool ignoreDisable)
9607 {
9608 if(ignoreDisable) return KeyInput[k];
9609 switch(k)
9610 {
9611 case KEY_F7:
9612 case KEY_F8:
9613 case KEY_F9:
9614 return KeyInput[k];
9615
9616 default:
9617 return KeyInput[k] && !disabledKeys[k];
9618 }
9619 }
9620
9621 // Reads (and then clears) the current frame key state directly.
9622 // Scripts can also modify `key_current_frame`.
9623 125 bool zc_readrawkey(int32_t k, bool ignoreDisable)
9624 {
9625
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 123 times.
125 if(zc_getrawkey(k, ignoreDisable))
9626 {
9627 2 _key[k]=key[k]=key_current_frame[k]=0;
9628 2 return true;
9629 }
9630 123 _key[k]=key[k]=key_current_frame[k]=0;
9631 123 return false;
9632 125 }
9633
9634 // Reads the current frame key state directly.
9635 // Scripts can also modify `key_current_frame`.
9636 43497761 bool zc_getrawkey(int32_t k, bool ignoreDisable)
9637 {
9638
2/2
✓ Branch 0 taken 36987119 times.
✓ Branch 1 taken 6510642 times.
43497761 if(ignoreDisable) return key_current_frame[k];
9639
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6510642 times.
6510642 switch(k)
9640 {
9641 case KEY_F7:
9642 case KEY_F8:
9643 case KEY_F9:
9644 return key_current_frame[k];
9645
9646 default:
9647
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6510642 times.
6510642 return key_current_frame[k] && !disabledKeys[k];
9648 }
9649 43497761 }
9650
9651 // Only used for a handful of keys, like tilde and Function keys.
9652 // This state is never read within the game.
9653 // It exists so that all keyboard input still functions during replay,
9654 // without inadvertently doing things like toggling throttling if the player
9655 // presses ~
9656 13021293 bool zc_get_system_key(int32_t k)
9657 {
9658 13021293 return key_system[k];
9659 }
9660
9661 // True for the _first_ frame of a key press.
9662 58595526 bool zc_read_system_key(int32_t k)
9663 {
9664 58595526 return key_system_press[k];
9665 }
9666
9667 826847978 bool is_system_key(int32_t k)
9668 {
9669
2/2
✓ Branch 0 taken 768252452 times.
✓ Branch 1 taken 58595526 times.
826847978 switch (k)
9670 {
9671 case KEY_BACKQUOTE:
9672 case KEY_CLOSEBRACE:
9673 case KEY_END:
9674 case KEY_HOME:
9675 case KEY_OPENBRACE:
9676 case KEY_PGDN:
9677 case KEY_PGUP:
9678 case KEY_TAB:
9679 case KEY_TILDE:
9680 58595526 return true;
9681 }
9682 768252452 return is_Fkey(k);
9683 826847978 }
9684
9685 6510614 void update_system_keys()
9686 {
9687
2/2
✓ Branch 0 taken 826847978 times.
✓ Branch 1 taken 6510614 times.
833358592 for (int32_t q = 0; q < 127; ++q)
9688 {
9689
2/2
✓ Branch 0 taken 136722894 times.
✓ Branch 1 taken 690125084 times.
826847978 if (!is_system_key(q))
9690 690125084 continue;
9691
9692 136722894 key_system[q] = key[q];
9693
1/2
✓ Branch 0 taken 136722894 times.
✗ Branch 1 not taken.
136722894 key_system_press[q] = key_system[q] && !key_system_previous[q];
9694 136722894 key_system_previous[q] = key_system[q];
9695 136722894 }
9696 6510614 }
9697
9698 7628080 void update_keys()
9699 {
9700
2/2
✓ Branch 0 taken 968766160 times.
✓ Branch 1 taken 7628080 times.
976394240 for (int32_t q = 0; q < 127; ++q)
9701 {
9702 // When replaying, replay.cpp takes care of updating `key_current_frame`.
9703
1/2
✓ Branch 0 taken 968766160 times.
✗ Branch 1 not taken.
968766160 if (!replay_is_replaying())
9704 key_current_frame[q] = key[q];
9705
9706
2/2
✓ Branch 0 taken 961653306 times.
✓ Branch 1 taken 7112854 times.
968766160 KeyPress[q] = key_current_frame[q] && !key_previous_frame[q];
9707 968766160 KeyInput[q] = key_current_frame[q];
9708 968766160 key_previous_frame[q] = key_current_frame[q];
9709 968766160 }
9710 7628080 }
9711
9712 bool zc_disablekey(int32_t k, bool val)
9713 {
9714 switch(k)
9715 {
9716 case KEY_F7:
9717 case KEY_F8:
9718 case KEY_F9:
9719 return false;
9720
9721 default:
9722 disabledKeys[k] = val;
9723 return true;
9724 }
9725 }
9726
9727 void zc_putpixel(int32_t layer, int32_t x, int32_t y, int32_t cset, int32_t color, int32_t timer)
9728 {
9729 timer=timer;
9730 particles.add(new particle(zfix(x), zfix(y), layer, cset, color));
9731 }
9732
9733 // these are here so that copy_dialog won't choke when compiling zelda
9734 int32_t d_alltriggerbutton_proc(int32_t, DIALOG*, int32_t)
9735 {
9736 return D_O_K;
9737 }
9738
9739 int32_t d_comboa_radio_proc(int32_t, DIALOG*, int32_t)
9740 {
9741 return D_O_K;
9742 }
9743
9744 int32_t d_comboabutton_proc(int32_t, DIALOG*, int32_t)
9745 {
9746 return D_O_K;
9747 }
9748
9749 int32_t d_ssdn_btn_proc(int32_t, DIALOG*, int32_t)
9750 {
9751 return D_O_K;
9752 }
9753
9754 int32_t d_ssdn_btn2_proc(int32_t, DIALOG*, int32_t)
9755 {
9756 return D_O_K;
9757 }
9758
9759 int32_t d_ssdn_btn3_proc(int32_t, DIALOG*, int32_t)
9760 {
9761 return D_O_K;
9762 }
9763
9764 int32_t d_ssdn_btn4_proc(int32_t, DIALOG*, int32_t)
9765 {
9766 return D_O_K;
9767 }
9768
9769 int32_t d_sslt_btn_proc(int32_t, DIALOG*, int32_t)
9770 {
9771 return D_O_K;
9772 }
9773
9774 int32_t d_sslt_btn2_proc(int32_t, DIALOG*, int32_t)
9775 {
9776 return D_O_K;
9777 }
9778
9779 int32_t d_sslt_btn3_proc(int32_t, DIALOG*, int32_t)
9780 {
9781 return D_O_K;
9782 }
9783
9784 int32_t d_sslt_btn4_proc(int32_t, DIALOG*, int32_t)
9785 {
9786 return D_O_K;
9787 }
9788
9789 int32_t d_ssrt_btn_proc(int32_t, DIALOG*, int32_t)
9790 {
9791 return D_O_K;
9792 }
9793
9794 int32_t d_ssrt_btn2_proc(int32_t, DIALOG*, int32_t)
9795 {
9796 return D_O_K;
9797 }
9798
9799 int32_t d_ssrt_btn3_proc(int32_t, DIALOG*, int32_t)
9800 {
9801 return D_O_K;
9802 }
9803
9804 int32_t d_ssrt_btn4_proc(int32_t, DIALOG*, int32_t)
9805 {
9806 return D_O_K;
9807 }
9808
9809 int32_t d_ssup_btn_proc(int32_t, DIALOG*, int32_t)
9810 {
9811 return D_O_K;
9812 }
9813
9814 int32_t d_ssup_btn2_proc(int32_t, DIALOG*, int32_t)
9815 {
9816 return D_O_K;
9817 }
9818
9819 int32_t d_ssup_btn3_proc(int32_t, DIALOG*, int32_t)
9820 {
9821 return D_O_K;
9822 }
9823
9824 int32_t d_ssup_btn4_proc(int32_t, DIALOG*, int32_t)
9825 {
9826 return D_O_K;
9827 }
9828
9829 int32_t d_tri_edit_proc(int32_t, DIALOG*, int32_t)
9830 {
9831 return D_O_K;
9832 }
9833
9834 int32_t d_triggerbutton_proc(int32_t, DIALOG*, int32_t)
9835 {
9836 return D_O_K;
9837 }
9838
9839 /*** end of zc_sys.cc ***/
9840
9841